summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/CardDAV/PhotoCache.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib/CardDAV/PhotoCache.php')
-rw-r--r--apps/dav/lib/CardDAV/PhotoCache.php42
1 files changed, 12 insertions, 30 deletions
diff --git a/apps/dav/lib/CardDAV/PhotoCache.php b/apps/dav/lib/CardDAV/PhotoCache.php
index 66391b268a6..777a0b0e169 100644
--- a/apps/dav/lib/CardDAV/PhotoCache.php
+++ b/apps/dav/lib/CardDAV/PhotoCache.php
@@ -34,12 +34,12 @@ use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\Files\SimpleFS\ISimpleFolder;
-use Psr\Log\LoggerInterface;
use Sabre\CardDAV\Card;
use Sabre\VObject\Document;
use Sabre\VObject\Parameter;
use Sabre\VObject\Property\Binary;
use Sabre\VObject\Reader;
+use Psr\Log\LoggerInterface;
class PhotoCache {
@@ -51,9 +51,7 @@ class PhotoCache {
'image/vnd.microsoft.icon' => 'ico',
];
- /** @var IAppData */
- protected $appData;
-
+ protected IAppData $appData;
protected LoggerInterface $logger;
/**
@@ -65,15 +63,9 @@ class PhotoCache {
}
/**
- * @param int $addressBookId
- * @param string $cardUri
- * @param int $size
- * @param Card $card
- *
- * @return ISimpleFile
* @throws NotFoundException
*/
- public function get($addressBookId, $cardUri, $size, Card $card) {
+ public function get(int $addressBookId, string $cardUri, int $size, Card $card): ISimpleFile {
$folder = $this->getFolder($addressBookId, $cardUri);
if ($this->isEmpty($folder)) {
@@ -91,17 +83,11 @@ class PhotoCache {
return $this->getFile($folder, $size);
}
- /**
- * @param ISimpleFolder $folder
- * @return bool
- */
- private function isEmpty(ISimpleFolder $folder) {
+ private function isEmpty(ISimpleFolder $folder): bool {
return $folder->getDirectoryListing() === [];
}
/**
- * @param ISimpleFolder $folder
- * @param Card $card
* @throws NotPermittedException
*/
private function init(ISimpleFolder $folder, Card $card): void {
@@ -124,11 +110,14 @@ class PhotoCache {
$file->putContent($data['body']);
}
- private function hasPhoto(ISimpleFolder $folder) {
+ private function hasPhoto(ISimpleFolder $folder): bool {
return !$folder->fileExists('nophoto');
}
- private function getFile(ISimpleFolder $folder, $size) {
+ /**
+ * @param float|-1 $size
+ */
+ private function getFile(ISimpleFolder $folder, $size): ISimpleFile {
$ext = $this->getExtension($folder);
if ($size === -1) {
@@ -189,8 +178,6 @@ class PhotoCache {
/**
* Get the extension of the avatar. If there is no avatar throw Exception
*
- * @param ISimpleFolder $folder
- * @return string
* @throws NotFoundException
*/
private function getExtension(ISimpleFolder $folder): string {
@@ -205,7 +192,7 @@ class PhotoCache {
/**
* @param Card $node
- * @return bool|array{body: string, Content-Type: string}
+ * @return false|array{body: string, Content-Type: string}
*/
private function getPhoto(Card $node) {
try {
@@ -220,8 +207,7 @@ class PhotoCache {
}
/**
- * @param Document $vObject
- * @return bool|array{body: string, Content-Type: string}
+ * @return false|array{body: string, Content-Type: string}
*/
public function getPhotoFromVObject(Document $vObject) {
try {
@@ -265,11 +251,7 @@ class PhotoCache {
return false;
}
- /**
- * @param string $cardData
- * @return \Sabre\VObject\Document
- */
- private function readCard($cardData) {
+ private function readCard(string $cardData): Document {
return Reader::read($cardData);
}