@@ -35,7 +35,7 @@ |
||
35 | 35 | try { |
36 | 36 | $env = $getEnv($name); |
37 | 37 | |
38 | - return ! empty($env) && 'null://null' !== $env; |
|
38 | + return !empty($env) && 'null://null' !== $env; |
|
39 | 39 | } catch (EnvNotFoundException $exception) { |
40 | 40 | return false; |
41 | 41 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | //Ensure the given attachment class is known to mapping |
120 | - if (! isset($this->folder_mapping[\get_class($attachment)])) { |
|
120 | + if (!isset($this->folder_mapping[\get_class($attachment)])) { |
|
121 | 121 | throw new \InvalidArgumentException('The given attachment class is not known! The passed class was: '.\get_class($attachment)); |
122 | 122 | } |
123 | 123 | //Ensure the attachment has an assigned element |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | |
204 | 204 | //Determine the old filepath |
205 | 205 | $old_path = $this->pathResolver->placeholderToRealPath($attachment->getPath()); |
206 | - if (! file_exists($old_path)) { |
|
206 | + if (!file_exists($old_path)) { |
|
207 | 207 | return $attachment; |
208 | 208 | } |
209 | 209 | |
210 | 210 | $filename = basename($old_path); |
211 | 211 | //If the basename is not one of the new unique on, we have to save the old filename |
212 | - if (! preg_match('/\w+-\w{13}\./', $filename)) { |
|
212 | + if (!preg_match('/\w+-\w{13}\./', $filename)) { |
|
213 | 213 | //Save filename to attachment field |
214 | 214 | $attachment->setFilename($attachment->getFilename()); |
215 | 215 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | protected function downloadURL(Attachment $attachment, array $options): Attachment |
240 | 240 | { |
241 | 241 | //Check if we are allowed to download files |
242 | - if (! $this->allow_attachments_downloads) { |
|
242 | + if (!$this->allow_attachments_downloads) { |
|
243 | 243 | throw new \RuntimeException('Download of attachments is not allowed!'); |
244 | 244 | } |
245 | 245 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | |
290 | 290 | //Check if we have a extension given |
291 | 291 | $pathinfo = pathinfo($filename); |
292 | - if (! empty($pathinfo['extension'])) { |
|
292 | + if (!empty($pathinfo['extension'])) { |
|
293 | 293 | $new_ext = $pathinfo['extension']; |
294 | 294 | } else { //Otherwise we have to guess the extension for the new file, based on its content |
295 | 295 | $new_ext = $this->mimeTypes->getExtensions($this->mimeTypes->guessMimeType($tmp_path))[0] ?? 'tmp'; |
@@ -183,7 +183,7 @@ |
||
183 | 183 | } |
184 | 184 | |
185 | 185 | //If the new string does not begin with a placeholder, it is invalid |
186 | - if (! preg_match('/^%\w+%/', $real_path)) { |
|
186 | + if (!preg_match('/^%\w+%/', $real_path)) { |
|
187 | 187 | return null; |
188 | 188 | } |
189 | 189 |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function attachmentToFile(Attachment $attachment): ?\SplFileInfo |
54 | 54 | { |
55 | - if ($attachment->isExternal() || ! $this->isFileExisting($attachment)) { |
|
55 | + if ($attachment->isExternal() || !$this->isFileExisting($attachment)) { |
|
56 | 56 | return null; |
57 | 57 | } |
58 | 58 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | return null; |
121 | 121 | } |
122 | 122 | |
123 | - if (! $this->isFileExisting($attachment)) { |
|
123 | + if (!$this->isFileExisting($attachment)) { |
|
124 | 124 | return null; |
125 | 125 | } |
126 | 126 |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | //Check for each element if it is valid: |
73 | 73 | foreach ($elements as $element) { |
74 | 74 | $element = trim($element); |
75 | - if (! preg_match('/^\.\w+$/', $element) // .ext is allowed |
|
76 | - && ! preg_match('/^[-\w.]+\/[-\w.]+/', $element) //Explicit MIME type is allowed |
|
77 | - && ! \in_array($element, static::ALLOWED_MIME_PLACEHOLDERS, false)) { //image/* is allowed |
|
75 | + if (!preg_match('/^\.\w+$/', $element) // .ext is allowed |
|
76 | + && !preg_match('/^[-\w.]+\/[-\w.]+/', $element) //Explicit MIME type is allowed |
|
77 | + && !\in_array($element, static::ALLOWED_MIME_PLACEHOLDERS, false)) { //image/* is allowed |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $element = 'video/*'; |
121 | 121 | } elseif ('audio' === $element || 'audio/' === $element) { |
122 | 122 | $element = 'audio/*'; |
123 | - } elseif (! preg_match('/^[-\w.]+\/[-\w.*]+/', $element) && 0 !== strpos($element, '.')) { |
|
123 | + } elseif (!preg_match('/^[-\w.]+\/[-\w.*]+/', $element) && 0 !== strpos($element, '.')) { |
|
124 | 124 | //Convert jpg to .jpg |
125 | 125 | $element = '.'.$element; |
126 | 126 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | { |
143 | 143 | $filter = trim($filter); |
144 | 144 | |
145 | - return $this->cache->get('filter_exts_'.md5($filter), function (ItemInterface $item) use ($filter) { |
|
145 | + return $this->cache->get('filter_exts_'.md5($filter), function(ItemInterface $item) use ($filter) { |
|
146 | 146 | $elements = explode(',', $filter); |
147 | 147 | $extensions = []; |
148 | 148 |
@@ -105,7 +105,7 @@ |
||
105 | 105 | */ |
106 | 106 | public function getThumbnailURL(Attachment $attachment, string $filter_name = 'thumbnail_sm'): string |
107 | 107 | { |
108 | - if (! $attachment->isPicture()) { |
|
108 | + if (!$attachment->isPicture()) { |
|
109 | 109 | throw new \InvalidArgumentException('Thumbnail creation only works for picture attachments!'); |
110 | 110 | } |
111 | 111 |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public function getListOfRessources(): array |
54 | 54 | { |
55 | 55 | try { |
56 | - return $this->cache->get('attachment_builtin_ressources', function () { |
|
56 | + return $this->cache->get('attachment_builtin_ressources', function() { |
|
57 | 57 | $results = []; |
58 | 58 | |
59 | 59 | $finder = new Finder(); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | protected function configureOptions(OptionsResolver $resolver): void |
136 | 136 | { |
137 | 137 | $resolver->setDefaults([ |
138 | - 'limit' => 15, //Given only 15 entries |
|
138 | + 'limit' => 15, //Given only 15 entries |
|
139 | 139 | //'allowed_extensions' => [], //Filter the filenames. For example ['jpg', 'jpeg'] to only get jpegs. |
140 | 140 | //'placeholders' => Attachment::BUILTIN_PLACEHOLDER, //By default use all builtin ressources, |
141 | 141 | 'empty_returns_all' => false, //Return the whole list of ressources when empty keyword is given |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function format($value, ?MeasurementUnit $unit = null, array $options = []) |
54 | 54 | { |
55 | - if (! is_numeric($value)) { |
|
55 | + if (!is_numeric($value)) { |
|
56 | 56 | throw new \InvalidArgumentException('$value must be an numeric value!'); |
57 | 57 | } |
58 | 58 | $value = (float) $value; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | //Otherwise just output it |
77 | - if (! empty($options['unit'])) { |
|
77 | + if (!empty($options['unit'])) { |
|
78 | 78 | $format_string = '%.'.$options['decimals'].'f '.$options['unit']; |
79 | 79 | } else { //Dont add space after number if no unit was specified |
80 | 80 | $format_string = '%.'.$options['decimals'].'f'; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | protected function configureOptions(OptionsResolver $resolver): void |
87 | 87 | { |
88 | 88 | $resolver->setDefaults([ |
89 | - 'show_prefix' => function (Options $options) { |
|
89 | + 'show_prefix' => function(Options $options) { |
|
90 | 90 | if (null !== $options['measurement_unit']) { |
91 | 91 | /** @var MeasurementUnit $unit */ |
92 | 92 | $unit = $options['measurement_unit']; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | return false; |
98 | 98 | }, |
99 | - 'is_integer' => function (Options $options) { |
|
99 | + 'is_integer' => function(Options $options) { |
|
100 | 100 | if (null !== $options['measurement_unit']) { |
101 | 101 | /** @var MeasurementUnit $unit */ |
102 | 102 | $unit = $options['measurement_unit']; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | return true; |
108 | 108 | }, |
109 | - 'unit' => function (Options $options) { |
|
109 | + 'unit' => function(Options $options) { |
|
110 | 110 | if (null !== $options['measurement_unit']) { |
111 | 111 | /** @var MeasurementUnit $unit */ |
112 | 112 | $unit = $options['measurement_unit']; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | $resolver->setAllowedTypes('decimals', 'int'); |
124 | 124 | |
125 | - $resolver->setNormalizer('decimals', function (Options $options, $value) { |
|
125 | + $resolver->setNormalizer('decimals', function(Options $options, $value) { |
|
126 | 126 | // If the unit is integer based, then dont show any decimals |
127 | 127 | if ($options['is_integer']) { |
128 | 128 | return 0; |
@@ -51,7 +51,7 @@ |
||
51 | 51 | public function format($value, ?Currency $currency = null, $decimals = 5, bool $show_all_digits = false) |
52 | 52 | { |
53 | 53 | $iso_code = $this->base_currency; |
54 | - if (null !== $currency && ! empty($currency->getIsoCode())) { |
|
54 | + if (null !== $currency && !empty($currency->getIsoCode())) { |
|
55 | 55 | $iso_code = $currency->getIsoCode(); |
56 | 56 | } |
57 | 57 |