@@ -21,5 +21,5 @@ |
||
21 | 21 | |
22 | 22 | public function add(ImageInterface $image): self; |
23 | 23 | |
24 | - public function get(string $key, bool $fallback=true): ?ImageInterface; |
|
24 | + public function get(string $key, bool $fallback = true): ?ImageInterface; |
|
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -38,7 +38,7 @@ |
||
38 | 38 | User $user, |
39 | 39 | string $metadataClass, |
40 | 40 | string $entityClass |
41 | - ){ |
|
41 | + ) { |
|
42 | 42 | |
43 | 43 | $this->user = $user; |
44 | 44 | $this->metadataClass = $metadataClass; |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | $data = $data['original']; |
74 | - $file = $data['tmp_name']; |
|
74 | + $file = $data['tmp_name']; |
|
75 | 75 | |
76 | - if(!is_readable($file)){ |
|
76 | + if (!is_readable($file)) { |
|
77 | 77 | throw new \Exception("File '$file' is unreadable."); |
78 | 78 | } |
79 | 79 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | /* @var ImageInterface $image */ |
99 | - foreach($images as $key => $image) { |
|
99 | + foreach ($images as $key => $image) { |
|
100 | 100 | $object->add($image); |
101 | 101 | } |
102 | 102 | |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | /* @var \Core\Entity\ImageMetadata $metadata */ |
139 | 139 | $metadata = $this->options->getMetadata(); |
140 | 140 | $fileManager = $this->fileManager; |
141 | - $name = ($prefix ? "$prefix-" : '') . $data['name']; |
|
142 | - $key = "" == $prefix ? "original":$prefix; |
|
141 | + $name = ($prefix ? "$prefix-" : '').$data['name']; |
|
142 | + $key = "" == $prefix ? "original" : $prefix; |
|
143 | 143 | $metadata->setContentType($data['type']); |
144 | 144 | $metadata->setBelongsTo($imageSetId); |
145 | 145 | $metadata->setKey($key); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | if (is_string($image)) { |
149 | 149 | $file = $image; |
150 | - }else{ |
|
150 | + } else { |
|
151 | 151 | $format = str_replace('image/', '', $data['type']); |
152 | 152 | $content = $image->get($format); |
153 | 153 | $file = '/tmp/php'.md5($content); |
@@ -45,12 +45,12 @@ |
||
45 | 45 | } |
46 | 46 | */ |
47 | 47 | $setterMethods = array(); |
48 | - if(method_exists($object, 'getSetters')){ |
|
48 | + if (method_exists($object, 'getSetters')) { |
|
49 | 49 | $setterMethods = $object->getSetters(); |
50 | 50 | } |
51 | 51 | |
52 | 52 | foreach ($data as $key => $value) { |
53 | - $setter = 'set' . ucfirst($key); |
|
53 | + $setter = 'set'.ucfirst($key); |
|
54 | 54 | if (in_array($setter, $setterMethods)) { |
55 | 55 | $object->$setter($value); |
56 | 56 | } else { |
@@ -28,6 +28,6 @@ |
||
28 | 28 | |
29 | 29 | public function getUri(): string |
30 | 30 | { |
31 | - return '/'.trim('file/Core.Images/' . $this->id . "/" . urlencode($this->name), '/'); |
|
31 | + return '/'.trim('file/Core.Images/'.$this->id."/".urlencode($this->name), '/'); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | \ No newline at end of file |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | { |
64 | 64 | $images = $this->images; |
65 | 65 | $metadata = $image->getMetadata(); |
66 | - if(!is_null($current = $this->get($metadata->getKey(), false))){ |
|
66 | + if (!is_null($current = $this->get($metadata->getKey(), false))) { |
|
67 | 67 | $index = $images->indexOf($current); |
68 | 68 | $images->remove($index); |
69 | 69 | } |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | |
74 | 74 | public function get(string $key, bool $fallback = true): ?ImageInterface |
75 | 75 | { |
76 | - foreach($this->images as $image){ |
|
77 | - try{ |
|
78 | - if(!is_null($metadata = $image->getMetadata())){ |
|
79 | - if($metadata->getKey() === $key){ |
|
76 | + foreach ($this->images as $image) { |
|
77 | + try { |
|
78 | + if (!is_null($metadata = $image->getMetadata())) { |
|
79 | + if ($metadata->getKey() === $key) { |
|
80 | 80 | return $image; |
81 | 81 | } |
82 | 82 | } |
83 | - }catch (\Exception $e){ |
|
83 | + } catch (\Exception $e) { |
|
84 | 84 | return null; |
85 | 85 | } |
86 | 86 | } |
@@ -94,17 +94,17 @@ |
||
94 | 94 | $size = $this->getLength(); |
95 | 95 | |
96 | 96 | if ($size >= 1073741824) { |
97 | - return round($size / 1073741824, 2) . ' GB'; |
|
97 | + return round($size / 1073741824, 2).' GB'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | if ($size >= 1048576) { |
101 | - return round($size / 1048576, 2) . ' MB'; |
|
101 | + return round($size / 1048576, 2).' MB'; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | if ($size >= 1024) { |
105 | - return round($size / 1024, 2) . ' kB'; |
|
105 | + return round($size / 1024, 2).' kB'; |
|
106 | 106 | } |
107 | 107 | |
108 | - return (string)$size; |
|
108 | + return (string) $size; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | \ No newline at end of file |
@@ -41,7 +41,7 @@ |
||
41 | 41 | * Image specifications. |
42 | 42 | */ |
43 | 43 | protected array $images = [ |
44 | - ImageSetInterface::THUMBNAIL => [100,100], |
|
44 | + ImageSetInterface::THUMBNAIL => [100, 100], |
|
45 | 45 | ]; |
46 | 46 | |
47 | 47 | /** |
@@ -69,11 +69,11 @@ |
||
69 | 69 | $proxyDir = $config->getProxyDir(); |
70 | 70 | $hydratorDir = $config->getHydratorDir(); |
71 | 71 | |
72 | - if(!is_dir($proxyDir)){ |
|
72 | + if (!is_dir($proxyDir)) { |
|
73 | 73 | mkdir($proxyDir, 0777, true); |
74 | 74 | } |
75 | 75 | |
76 | - if(!is_dir($hydratorDir)){ |
|
76 | + if (!is_dir($hydratorDir)) { |
|
77 | 77 | mkdir($hydratorDir, 0777, true); |
78 | 78 | } |
79 | 79 | } |