Test Failed
Push — fix/media-validation ( 3351fe...390e9c )
by Ben
25:53
created
src/Media/Application/ImageFieldHandler.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
             $request->input('images.'.$field->getName(), []),
18 18
         ], $field, $request);
19 19
 
20
-        foreach([MediaRequest::NEW, MediaRequest::REPLACE, MediaRequest::DETACH] as $action) {
21
-            foreach($mediaRequest->getByKey($action) as $input) {
20
+        foreach ([MediaRequest::NEW, MediaRequest::REPLACE, MediaRequest::DETACH] as $action) {
21
+            foreach ($mediaRequest->getByKey($action) as $input) {
22 22
                 $this->$action($model, $input);
23 23
             }
24 24
         }
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
     private function new(HasAsset $model, MediaRequestInput $mediaRequestInput): Asset
56 56
     {
57
-        if($mediaRequestInput->metadata('existing_asset')) {
57
+        if ($mediaRequestInput->metadata('existing_asset')) {
58 58
 
59 59
             $existingAsset = Asset::find($mediaRequestInput->value());
60 60
 
Please login to merge, or discard this patch.
src/Media/Application/FileFieldHandler.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
             $request->input('files.'.$field->getName(), []),
20 20
         ], $field, $request);
21 21
 
22
-        foreach([MediaRequest::NEW, MediaRequest::REPLACE, MediaRequest::DETACH] as $action) {
23
-            foreach($mediaRequest->getByKey($action) as $input) {
22
+        foreach ([MediaRequest::NEW, MediaRequest::REPLACE, MediaRequest::DETACH] as $action) {
23
+            foreach ($mediaRequest->getByKey($action) as $input) {
24 24
                 $this->$action($model, $input);
25 25
             }
26 26
         }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
     private function new(HasAsset $model, MediaRequestInput $mediaRequestInput): Asset
71 71
     {
72
-        if($mediaRequestInput->metadata('existing_asset')) {
72
+        if ($mediaRequestInput->metadata('existing_asset')) {
73 73
 
74 74
             $existingAsset = Asset::find($mediaRequestInput->value());
75 75
 
Please login to merge, or discard this patch.
src/Media/Application/AbstractMediaFieldHandler.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
     {
32 32
         $mediaRequest = new MediaRequest();
33 33
 
34
-        foreach($requests as $requestData){
35
-            foreach($requestData as $locale => $filesPerLocale) {
36
-                foreach($filesPerLocale as $action => $files) {
37
-                    foreach($files as $k => $file) {
34
+        foreach ($requests as $requestData) {
35
+            foreach ($requestData as $locale => $filesPerLocale) {
36
+                foreach ($filesPerLocale as $action => $files) {
37
+                    foreach ($files as $k => $file) {
38 38
                         $mediaRequest->add($action, new MediaRequestInput(
39 39
                             $file, $locale, $field->getKey(), [
40 40
                                 'index' => $k, // index key is used for replace method to indicate the current asset id
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
      */
61 61
     protected function sluggifyFilename(string $filename): string
62 62
     {
63
-        if(false === strpos($filename, '.')) return $filename;
63
+        if (false === strpos($filename, '.')) return $filename;
64 64
 
65
-        $extension = substr($filename, strrpos($filename, '.') + 1);
65
+        $extension = substr($filename, strrpos($filename, '.')+1);
66 66
         $filename = substr($filename, 0, strrpos($filename, '.'));
67 67
 
68
-        return Str::slug($filename) . '.' . $extension;
68
+        return Str::slug($filename).'.'.$extension;
69 69
     }
70 70
 }
Please login to merge, or discard this patch.
src/Fields/ValidationRules/ImageFieldMinRule.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,19 +10,19 @@  discard block
 block discarded – undo
10 10
     {
11 11
         $value = $this->normalizePayload($value);
12 12
 
13
-        foreach([MediaRequest::NEW, MediaRequest::REPLACE] as $type) {
14
-            foreach($value[$type] as $file) {
15
-                if($file && false !== $this->validateMin($attribute, $file, $params)) {
13
+        foreach ([MediaRequest::NEW, MediaRequest::REPLACE] as $type) {
14
+            foreach ($value[$type] as $file) {
15
+                if ($file && false !== $this->validateMin($attribute, $file, $params)) {
16 16
                     return true;
17 17
                 }
18 18
             }
19 19
         }
20 20
 
21 21
         $validator->setCustomMessages([
22
-            'imagefield_min' => 'De :attribute is te klein en dient groter te zijn dan ' . implode(',',$params) .'Kb.',
22
+            'imagefield_min' => 'De :attribute is te klein en dient groter te zijn dan '.implode(',', $params).'Kb.',
23 23
         ]);
24 24
 
25
-        if(!isset($validator->customAttributes[$attribute])) {
25
+        if (!isset($validator->customAttributes[$attribute])) {
26 26
             $validator->addCustomAttributes([
27 27
                 $attribute => 'afbeelding',
28 28
             ]);
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
     public function validateMin($attribute, $value, $parameters)
36 36
     {
37
-        if($this->refersToExistingAsset($value)) {
37
+        if ($this->refersToExistingAsset($value)) {
38 38
             return $this->validateAssetMin($this->existingAsset($value), $parameters);
39 39
         }
40 40
 
Please login to merge, or discard this patch.
src/Fields/ValidationRules/ImageFieldMaxRule.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,19 +10,19 @@  discard block
 block discarded – undo
10 10
     {
11 11
         $value = $this->normalizePayload($value);
12 12
 
13
-        foreach([MediaRequest::NEW, MediaRequest::REPLACE] as $type) {
14
-            foreach($value[$type] as $file) {
15
-                if($file && false !== $this->validateMax($attribute, $file, $params)) {
13
+        foreach ([MediaRequest::NEW, MediaRequest::REPLACE] as $type) {
14
+            foreach ($value[$type] as $file) {
15
+                if ($file && false !== $this->validateMax($attribute, $file, $params)) {
16 16
                     return true;
17 17
                 }
18 18
             }
19 19
         }
20 20
 
21 21
         $validator->setCustomMessages([
22
-            'imagefield_max' => 'De :attribute is te groot en dient kleiner te zijn dan ' . implode(',',$params) .'Kb.',
22
+            'imagefield_max' => 'De :attribute is te groot en dient kleiner te zijn dan '.implode(',', $params).'Kb.',
23 23
         ]);
24 24
 
25
-        if(!isset($validator->customAttributes[$attribute])) {
25
+        if (!isset($validator->customAttributes[$attribute])) {
26 26
             $validator->addCustomAttributes([
27 27
                 $attribute => 'afbeelding',
28 28
             ]);
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
     public function validateMax($attribute, $value, $parameters)
36 36
     {
37
-        if($this->refersToExistingAsset($value)) {
37
+        if ($this->refersToExistingAsset($value)) {
38 38
             return $this->validateAssetMax($this->existingAsset($value), $parameters);
39 39
         }
40 40
 
Please login to merge, or discard this patch.
src/Fields/ValidationRules/ImageFieldDimensionsRule.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
         }
20 20
 
21 21
         $validator->setCustomMessages([
22
-            'imagefield_dimensions' => 'De :attribute heeft niet de juiste afmetingen: ' . implode(',', $this->humanReadableParams($params)),
22
+            'imagefield_dimensions' => 'De :attribute heeft niet de juiste afmetingen: '.implode(',', $this->humanReadableParams($params)),
23 23
         ]);
24 24
 
25 25
         if (!isset($validator->customAttributes[$attribute])) {
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
     public function validateDimensions($attribute, $value, $parameters)
36 36
     {
37
-        if($this->refersToExistingAsset($value)) {
37
+        if ($this->refersToExistingAsset($value)) {
38 38
             return $this->validateAssetDimensions($this->existingAsset($value), $parameters);
39 39
         }
40 40
 
Please login to merge, or discard this patch.