@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | $normalizedData = [ |
42 | 42 | '@id' => $this->iriGenerator->iri($mediaObject->getMediaObjectId()), |
43 | 43 | '@type' => $this->serializeMimeType($mediaObject->getMimeType()), |
44 | - 'contentUrl' => (string) $mediaObject->getSourceLocation(), |
|
45 | - 'thumbnailUrl' => (string) $mediaObject->getSourceLocation(), |
|
46 | - 'description' => (string) $mediaObject->getDescription(), |
|
47 | - 'copyrightHolder' => (string) $mediaObject->getCopyrightHolder(), |
|
48 | - 'inLanguage' => (string) $mediaObject->getLanguage(), |
|
44 | + 'contentUrl' => (string)$mediaObject->getSourceLocation(), |
|
45 | + 'thumbnailUrl' => (string)$mediaObject->getSourceLocation(), |
|
46 | + 'description' => (string)$mediaObject->getDescription(), |
|
47 | + 'copyrightHolder' => (string)$mediaObject->getCopyrightHolder(), |
|
48 | + 'inLanguage' => (string)$mediaObject->getLanguage(), |
|
49 | 49 | ]; |
50 | 50 | |
51 | 51 | return $normalizedData; |
@@ -53,18 +53,18 @@ discard block |
||
53 | 53 | |
54 | 54 | public function serializeMimeType(MIMEType $mimeType) |
55 | 55 | { |
56 | - $typeParts = explode('/', (string) $mimeType); |
|
56 | + $typeParts = explode('/', (string)$mimeType); |
|
57 | 57 | $type = array_shift($typeParts); |
58 | 58 | |
59 | 59 | if ($type === 'image') { |
60 | 60 | return 'schema:ImageObject'; |
61 | 61 | } |
62 | 62 | |
63 | - if ((string) $mimeType === 'application/octet-stream') { |
|
63 | + if ((string)$mimeType === 'application/octet-stream') { |
|
64 | 64 | return 'schema:mediaObject'; |
65 | 65 | } |
66 | 66 | |
67 | - throw new UnsupportedException('Unsupported MIME-type "'. $mimeType .'"'); |
|
67 | + throw new UnsupportedException('Unsupported MIME-type "'.$mimeType.'"'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | public function deserialize($data, $type, $format, array $context = array()) |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | ) { |
79 | 79 | try { |
80 | 80 | $existingMediaObject = $this->repository->load($id); |
81 | - $this->logger->info('Trying to create media with id: ' .$id . ' but it already exists. Using existing Media Object!'); |
|
81 | + $this->logger->info('Trying to create media with id: '.$id.' but it already exists. Using existing Media Object!'); |
|
82 | 82 | |
83 | 83 | return $existingMediaObject; |
84 | 84 | } catch (AggregateNotFoundException $exception) { |
85 | - $this->logger->info('No existing media with id: ' .$id . ' found. Creating a new Media Object!'); |
|
85 | + $this->logger->info('No existing media with id: '.$id.' found. Creating a new Media Object!'); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $mediaObject = MediaObject::create( |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | $this->filesystem->rename( |
119 | 119 | $uploadImage->getFilePath(), |
120 | - $this->mediaDirectory . '/' . $destinationPath |
|
120 | + $this->mediaDirectory.'/'.$destinationPath |
|
121 | 121 | ); |
122 | 122 | |
123 | 123 | $this->create( |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $uploadImage->getLanguage() |
130 | 130 | ); |
131 | 131 | |
132 | - $jobInfo = ['file_id' => (string) $uploadImage->getFileId()]; |
|
132 | + $jobInfo = ['file_id' => (string)$uploadImage->getFileId()]; |
|
133 | 133 | $this->logger->info('job_info', $jobInfo); |
134 | 134 | } |
135 | 135 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | public function get(UUID $fileId) |
140 | 140 | { |
141 | 141 | try { |
142 | - $mediaObject = $this->repository->load((string) $fileId); |
|
142 | + $mediaObject = $this->repository->load((string)$fileId); |
|
143 | 143 | } catch (AggregateNotFoundException $e) { |
144 | 144 | throw new MediaObjectNotFoundException( |
145 | 145 | sprintf("Media object with id '%s' not found", $fileId), |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | $image = new Image( |
164 | 164 | $mediaObject->getMediaObjectId(), |
165 | 165 | $mediaObject->getMimeType(), |
166 | - new Description((string) $mediaObject->getDescription()), |
|
167 | - new CopyrightHolder((string) $mediaObject->getCopyrightHolder()), |
|
166 | + new Description((string)$mediaObject->getDescription()), |
|
167 | + new CopyrightHolder((string)$mediaObject->getCopyrightHolder()), |
|
168 | 168 | $mediaObject->getSourceLocation(), |
169 | 169 | $mediaObject->getLanguage() |
170 | 170 | ); |
@@ -58,7 +58,7 @@ |
||
58 | 58 | $mainLanguage = isset($body->mainLanguage) ? $body->mainLanguage : 'nl'; |
59 | 59 | |
60 | 60 | if (is_string($body->name)) { |
61 | - $body->name = (object) [ |
|
61 | + $body->name = (object)[ |
|
62 | 62 | $mainLanguage => $body->name, |
63 | 63 | ]; |
64 | 64 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | { |
29 | 29 | $body = $jsonDocument->getBody(); |
30 | 30 | |
31 | - $castLanguageToString = function (Language $language) { |
|
31 | + $castLanguageToString = function(Language $language) { |
|
32 | 32 | return $language->getCode(); |
33 | 33 | }; |
34 | 34 |
@@ -60,7 +60,7 @@ |
||
60 | 60 | $mainLanguage = isset($body->mainLanguage) ? $body->mainLanguage : 'nl'; |
61 | 61 | |
62 | 62 | if (isset($body->address->streetAddress)) { |
63 | - $body->address = (object) [ |
|
63 | + $body->address = (object)[ |
|
64 | 64 | $mainLanguage => $body->address, |
65 | 65 | ]; |
66 | 66 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | private function getHandleMethodName($event) |
26 | 26 | { |
27 | 27 | $classParts = explode('\\', get_class($event)); |
28 | - $methodName = 'apply' . end($classParts); |
|
28 | + $methodName = 'apply'.end($classParts); |
|
29 | 29 | |
30 | 30 | if (!method_exists($this, $methodName)) { |
31 | 31 | return null; |
@@ -98,7 +98,7 @@ |
||
98 | 98 | private function getLanguageStringsAsValueObjects(array $languageStrings) |
99 | 99 | { |
100 | 100 | return array_map( |
101 | - function ($languageString) { |
|
101 | + function($languageString) { |
|
102 | 102 | return new Language($languageString); |
103 | 103 | }, |
104 | 104 | $languageStrings |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | |
196 | 196 | // Calculate the UDB2 imported labels. |
197 | 197 | $udb3Labels = array_map( |
198 | - function (LabelRelation $labelRelation) { |
|
198 | + function(LabelRelation $labelRelation) { |
|
199 | 199 | return $labelRelation->getLabelName()->toNative(); |
200 | 200 | }, |
201 | 201 | $this->readRepository->getLabelRelationsForItem($relationId) |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | // Only save the UDB2 labels, because the UDB3 labels are still present. |
209 | 209 | foreach ($udb2Labels as $label) { |
210 | 210 | $this->writeRepository->save( |
211 | - new LabelName((string) $label), |
|
211 | + new LabelName((string)$label), |
|
212 | 212 | $relationType, |
213 | 213 | $relationId, |
214 | 214 | true |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | { |
225 | 225 | $labelRelation = null; |
226 | 226 | |
227 | - $labelName = new LabelName((string) $labelEvent->getLabel()); |
|
227 | + $labelName = new LabelName((string)$labelEvent->getLabel()); |
|
228 | 228 | $relationType = $this->offerTypeResolver->getRelationType($labelEvent); |
229 | 229 | $relationId = new StringLiteral($labelEvent->getItemId()); |
230 | 230 |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | if (preg_match('/^apply(.+)$/', $method, $matches)) { |
153 | 153 | $event = $matches[1]; |
154 | - $classNameMethod = 'get' . $event . 'ClassName'; |
|
154 | + $classNameMethod = 'get'.$event.'ClassName'; |
|
155 | 155 | |
156 | 156 | if (method_exists($this, $classNameMethod)) { |
157 | 157 | $eventFullClassName = call_user_func(array($this, $classNameMethod)); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | $labelsProperty = $labelAdded->getLabel()->isVisible() ? 'labels' : 'hiddenLabels'; |
293 | 293 | |
294 | 294 | $labels = isset($offerLd->{$labelsProperty}) ? $offerLd->{$labelsProperty} : []; |
295 | - $label = (string) $labelAdded->getLabel(); |
|
295 | + $label = (string)$labelAdded->getLabel(); |
|
296 | 296 | |
297 | 297 | $labels[] = $label; |
298 | 298 | $offerLd->{$labelsProperty} = array_unique($labels); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | if (isset($offerLd->{$labelsProperty}) && is_array($offerLd->{$labelsProperty})) { |
319 | 319 | $offerLd->{$labelsProperty} = array_filter( |
320 | 320 | $offerLd->{$labelsProperty}, |
321 | - function ($label) use ($labelRemoved) { |
|
321 | + function($label) use ($labelRemoved) { |
|
322 | 322 | return !$labelRemoved->getLabel()->equals( |
323 | 323 | new Label($label) |
324 | 324 | ); |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | return; |
419 | 419 | } |
420 | 420 | |
421 | - $imageId = (string) $imageRemoved->getImage()->getMediaObjectId(); |
|
421 | + $imageId = (string)$imageRemoved->getImage()->getMediaObjectId(); |
|
422 | 422 | |
423 | 423 | /** |
424 | 424 | * Matches any object that is not the removed image. |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * @return bool |
430 | 430 | * Returns true when the media object does not match the image to remove. |
431 | 431 | */ |
432 | - $shouldNotBeRemoved = function ($mediaObject) use ($imageId) { |
|
432 | + $shouldNotBeRemoved = function($mediaObject) use ($imageId) { |
|
433 | 433 | $containsId = !!strpos($mediaObject->{'@id'}, $imageId); |
434 | 434 | return !$containsId; |
435 | 435 | }; |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | $document = $this->loadDocumentFromRepository($mainImageSelected); |
469 | 469 | $offerLd = $document->getBody(); |
470 | 470 | $imageId = $mainImageSelected->getImage()->getMediaObjectId(); |
471 | - $mediaObjectMatcher = function ($matchingMediaObject, $currentMediaObject) use ($imageId) { |
|
471 | + $mediaObjectMatcher = function($matchingMediaObject, $currentMediaObject) use ($imageId) { |
|
472 | 472 | if (!$matchingMediaObject && $this->mediaObjectMatchesId($currentMediaObject, $imageId)) { |
473 | 473 | $matchingMediaObject = $currentMediaObject; |
474 | 474 | } |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | */ |
494 | 494 | protected function mediaObjectMatchesId($mediaObject, UUID $mediaObjectId) |
495 | 495 | { |
496 | - return strpos($mediaObject->{'@id'}, (string) $mediaObjectId) > 0; |
|
496 | + return strpos($mediaObject->{'@id'}, (string)$mediaObjectId) > 0; |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | /** |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | $document = $this->loadDocumentFromRepository($typicalAgeRangeUpdated); |
658 | 658 | |
659 | 659 | $offerLd = $document->getBody(); |
660 | - $offerLd->typicalAgeRange = (string) $typicalAgeRangeUpdated->getTypicalAgeRange(); |
|
660 | + $offerLd->typicalAgeRange = (string)$typicalAgeRangeUpdated->getTypicalAgeRange(); |
|
661 | 661 | |
662 | 662 | return $document->withBody($offerLd); |
663 | 663 | } |
@@ -785,14 +785,14 @@ discard block |
||
785 | 785 | $images = $imagesEvent->getImages(); |
786 | 786 | $currentMediaObjects = isset($offerLd->mediaObject) ? $offerLd->mediaObject : []; |
787 | 787 | $dutchMediaObjects = array_map( |
788 | - function (Image $image) { |
|
788 | + function(Image $image) { |
|
789 | 789 | return $this->mediaObjectSerializer->serialize($image, 'json-ld'); |
790 | 790 | }, |
791 | 791 | $images->toArray() |
792 | 792 | ); |
793 | 793 | $translatedMediaObjects = array_filter( |
794 | 794 | $currentMediaObjects, |
795 | - function ($image) { |
|
795 | + function($image) { |
|
796 | 796 | return $image->inLanguage !== 'nl'; |
797 | 797 | } |
798 | 798 | ); |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | } |
806 | 806 | |
807 | 807 | if (isset($mainImage)) { |
808 | - $offerLd->image = (string) $mainImage->getSourceLocation(); |
|
808 | + $offerLd->image = (string)$mainImage->getSourceLocation(); |
|
809 | 809 | } |
810 | 810 | } |
811 | 811 |