diff --git a/lib/Model/ClassificationLabel.php b/lib/Model/ClassificationLabel.php index 437c35c..7a315db 100644 --- a/lib/Model/ClassificationLabel.php +++ b/lib/Model/ClassificationLabel.php @@ -115,7 +115,7 @@ public static function fromArray(array $labelRaw): ClassificationLabel { if (!isset($labelRaw['index'], $labelRaw['tag'], $labelRaw['keywords'], $labelRaw['categories'], $labelRaw['searchExpressions'], $labelRaw['regularExpressions'], $labelRaw['metadataItems'])) { throw new \ValueError(); } - $metadata = array_values(array_filter(array_map(fn($item) => MetadataItem::fromArray($item), $labelRaw['metadataItems']), fn($item) => $item->getKey() !== '')); + $metadata = array_values(array_filter(array_map(fn ($item) => MetadataItem::fromArray($item), $labelRaw['metadataItems']), fn ($item) => $item->getKey() !== '')); return new ClassificationLabel($labelRaw['index'], $labelRaw['tag'], $labelRaw['keywords'], $labelRaw['categories'], $labelRaw['searchExpressions'], $labelRaw['regularExpressions'], $metadata); } @@ -127,7 +127,7 @@ public function toArray() : array { 'categories' => $this->getBailsCategories(), 'searchExpressions' => $this->getSearchExpressions(), 'regularExpressions' => $this->getRegularExpressions(), - 'metadataItems' => array_map(fn($item) => $item->toArray(), $this->getMetadataItems()), + 'metadataItems' => array_map(fn ($item) => $item->toArray(), $this->getMetadataItems()), ]; } diff --git a/lib/Model/MetadataItem.php b/lib/Model/MetadataItem.php index 8d78fd9..43ac154 100644 --- a/lib/Model/MetadataItem.php +++ b/lib/Model/MetadataItem.php @@ -10,29 +10,24 @@ class MetadataItem { */ public function __construct( private string $key, - private string $value) - { + private string $value) { } - public function getKey(): string - { + public function getKey(): string { return $this->key; } - public function setKey(string $key): MetadataItem - { + public function setKey(string $key): MetadataItem { $this->key = $key; return $this; } - public function getValue(): string - { + public function getValue(): string { return $this->value; } - public function setValue(string $value): MetadataItem - { + public function setValue(string $value): MetadataItem { $this->value = $value; return $this; } diff --git a/lib/Providers/MetadataProviders/MicrosoftOfficeMetadataProvider.php b/lib/Providers/MetadataProviders/MicrosoftOfficeMetadataProvider.php index b1b1061..290cc0b 100644 --- a/lib/Providers/MetadataProviders/MicrosoftOfficeMetadataProvider.php +++ b/lib/Providers/MetadataProviders/MicrosoftOfficeMetadataProvider.php @@ -11,8 +11,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Service; -class MicrosoftOfficeMetadataProvider implements IMetadataProvider -{ +class MicrosoftOfficeMetadataProvider implements IMetadataProvider { public const ELEMENT_PROPERTIES = '{http://schemas.openxmlformats.org/officeDocument/2006/custom-properties}Properties'; public const ELEMENT_PROPERTY = '{http://schemas.openxmlformats.org/officeDocument/2006/custom-properties}property'; @@ -68,7 +67,7 @@ public function getMetadataForFile(File $file): array { if ( $child['name'] === self::ELEMENT_PROPERTY && isset($child['attributes'][self::ATTRIBUTE_NAME], $child['value'][0], $child['value'][0]['value'])) { - $items[] = new MetadataItem( $child['attributes'][self::ATTRIBUTE_NAME], $child['value'][0]['value']); + $items[] = new MetadataItem($child['attributes'][self::ATTRIBUTE_NAME], $child['value'][0]['value']); } } return $items; diff --git a/lib/Service/BailsPolicyProviderService.php b/lib/Service/BailsPolicyProviderService.php index ccf4366..7efebd6 100644 --- a/lib/Service/BailsPolicyProviderService.php +++ b/lib/Service/BailsPolicyProviderService.php @@ -4,9 +4,9 @@ namespace OCA\Files_Confidential\Service; +use OCA\Files_Confidential\Contract\IBailsPolicy; use OCA\Files_Confidential\Providers\BailsProviders\MicrosoftOfficeBailsProvider; use OCA\Files_Confidential\Providers\BailsProviders\OpenDocumentBailsProvider; -use OCA\Files_Confidential\Contract\IBailsPolicy; use OCP\Files\File; class BailsPolicyProviderService { diff --git a/lib/Service/ClassificationService.php b/lib/Service/ClassificationService.php index f0bf105..9233b91 100644 --- a/lib/Service/ClassificationService.php +++ b/lib/Service/ClassificationService.php @@ -43,7 +43,7 @@ public function getClassificationLabelForFile(File $file) : ?IClassificationLabe $content = $this->contentService->getContentForFile($file); $labelFromContent = ClassificationLabel::findLabelsInText($content, $labels); - $labels = array_values(array_filter([$labelFromMetadata, $labelFromPolicy, $labelFromContent], fn($label) => $label !== null)); + $labels = array_values(array_filter([$labelFromMetadata, $labelFromPolicy, $labelFromContent], fn ($label) => $label !== null)); if (count($labels) === 0) { return null; diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index 006ae91..6915b68 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -7,7 +7,6 @@ use OCA\Files_Confidential\Model\ClassificationLabel; use OCP\IConfig; use Psr\Log\LoggerInterface; -use Safe\Exceptions\JsonException; class SettingsService { public function __construct( diff --git a/test/MetadataProviderTest.php b/test/MetadataProviderTest.php index eebedd1..66d3855 100644 --- a/test/MetadataProviderTest.php +++ b/test/MetadataProviderTest.php @@ -1,7 +1,6 @@ testFile = $this->userFolder->newFile('/test.pptx', file_get_contents(__DIR__ . '/res/test_mips_metadata.pptx')); /** @var \OCA\Files_Confidential\Contract\IMetadataProvider $provider */ - $provider = \OC::$server->get(\OCA\Files_Confidential\Providers\MetadataProviders\MicrosoftOfficeMetadataProvider::class); + $provider = \OC::$server->get(MicrosoftOfficeMetadataProvider::class); $metadataItems = $provider->getMetadataForFile($this->testFile); - $array = array_map(fn($item) => $item->toArray(), $metadataItems); + $array = array_map(fn ($item) => $item->toArray(), $metadataItems); self::assertEquals([ ['key' => "MSIP_Label_9a7859fa-fb81-458d-9040-c3b7cffe6362_Enabled", 'value' => 'true'], ['key' => "MSIP_Label_9a7859fa-fb81-458d-9040-c3b7cffe6362_SetDate", 'value' => '2024-01-18T23:42:17Z'],