Test Failed
Push — fix/media-validation ( 6403fc...e4808d )
by Ben
07:03
created
src/Fields/ValidationRules/FileFieldMimetypesRule.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  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->validateMimetypes($attribute, $file, $params)) {
13
+        foreach ([MediaRequest::NEW, MediaRequest::REPLACE] as $type) {
14
+            foreach ($value[$type] as $file) {
15
+                if ($file && false === $this->validateMimetypes($attribute, $file, $params)) {
16 16
                     $this->addCustomValidationMessage($attribute, $params, $validator);
17 17
                     return false;
18 18
                 }
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function validateMimetypes($attribute, $value, $parameters)
26 26
     {
27
-        if($this->refersToExistingAsset($value)) {
27
+        if ($this->refersToExistingAsset($value)) {
28 28
             return $this->validateAssetMimetypes($this->existingAsset($value), $parameters);
29 29
         }
30 30
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     private function addCustomValidationMessage($attribute, $params, $validator): void
40 40
     {
41 41
         $validator->setCustomMessages([
42
-            'filefield_mimetypes' => 'De :attribute is niet het juiste bestandstype. Volgende types zijn geldig: ' . implode(', ', $params),
42
+            'filefield_mimetypes' => 'De :attribute is niet het juiste bestandstype. Volgende types zijn geldig: '.implode(', ', $params),
43 43
         ]);
44 44
 
45 45
         if (!isset($validator->customAttributes[$attribute])) {
Please login to merge, or discard this patch.
src/Fields/ValidationRules/FileFieldDimensionsRule.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  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->validateDimensions($attribute, $file, $params)) {
13
+        foreach ([MediaRequest::NEW, MediaRequest::REPLACE] as $type) {
14
+            foreach ($value[$type] as $file) {
15
+                if ($file && false === $this->validateDimensions($attribute, $file, $params)) {
16 16
                     $this->addCustomValidationMessage($attribute, $params, $validator);
17 17
                     return false;
18 18
                 }
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function validateDimensions($attribute, $value, $parameters)
26 26
     {
27
-        if($this->refersToExistingAsset($value)) {
27
+        if ($this->refersToExistingAsset($value)) {
28 28
             return $this->validateAssetDimensions($this->existingAsset($value), $parameters);
29 29
         }
30 30
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     private function addCustomValidationMessage($attribute, $params, $validator): void
40 40
     {
41 41
         $validator->setCustomMessages([
42
-            'filefield_dimensions' => 'De :attribute heeft niet de juiste afmetingen: ' . implode(', ', $params),
42
+            'filefield_dimensions' => 'De :attribute heeft niet de juiste afmetingen: '.implode(', ', $params),
43 43
         ]);
44 44
 
45 45
         if (!isset($validator->customAttributes[$attribute])) {
Please login to merge, or discard this patch.
src/Fields/ValidationRules/ImageFieldRequiredRule.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
     {
11 11
         $value = $this->normalizePayloadIncludingExistingMedia($value);
12 12
 
13
-        foreach([MediaRequest::NEW, MediaRequest::REPLACE] as $type) {
14
-            if(is_array($value[$type]) && !empty($value[$type])) {
13
+        foreach ([MediaRequest::NEW, MediaRequest::REPLACE] as $type) {
14
+            if (is_array($value[$type]) && !empty($value[$type])) {
15 15
                 return true;
16 16
             }
17 17
         }
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
             'imagefield_required' => 'De :attribute is verplicht.',
21 21
         ]);
22 22
 
23
-        if(!isset($validator->customAttributes[$attribute])) {
23
+        if (!isset($validator->customAttributes[$attribute])) {
24 24
             $validator->addCustomAttributes([
25 25
                 $attribute => 'afbeelding',
26 26
             ]);
Please login to merge, or discard this patch.
src/Fields/ValidationRules/FileFieldRequiredRule.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
     {
11 11
         $value = $this->normalizePayloadIncludingExistingMedia($value);
12 12
 
13
-        foreach([MediaRequest::NEW, MediaRequest::REPLACE] as $type) {
14
-            if(is_array($value[$type]) && !empty($value[$type])) {
13
+        foreach ([MediaRequest::NEW, MediaRequest::REPLACE] as $type) {
14
+            if (is_array($value[$type]) && !empty($value[$type])) {
15 15
                 return true;
16 16
             }
17 17
         }
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
             'filefield_required' => 'De :attribute is verplicht.',
21 21
         ]);
22 22
 
23
-        if(!isset($validator->customAttributes[$attribute])) {
23
+        if (!isset($validator->customAttributes[$attribute])) {
24 24
             $validator->addCustomAttributes([
25 25
                 $attribute => 'afbeelding',
26 26
             ]);
Please login to merge, or discard this patch.
src/Fields/ValidationRules/ImageFieldDimensionsRule.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
     private function addCustomValidationMessage($attribute, $params, $validator): void
84 84
     {
85 85
         $validator->setCustomMessages([
86
-            'imagefield_dimensions' => 'De :attribute heeft niet de juiste afmetingen: ' . implode(', ', $this->humanReadableParams($params)),
86
+            'imagefield_dimensions' => 'De :attribute heeft niet de juiste afmetingen: '.implode(', ', $this->humanReadableParams($params)),
87 87
         ]);
88 88
 
89 89
         if (!isset($validator->customAttributes[$attribute])) {
Please login to merge, or discard this patch.
src/Fields/ValidationRules/ImageFieldMinRule.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  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
 
17 17
                     $this->addCustomValidationMessage($attribute, $params, $validator);
18 18
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
     public function validateMin($attribute, $value, $parameters)
28 28
     {
29
-        if($this->refersToExistingAsset($value)) {
29
+        if ($this->refersToExistingAsset($value)) {
30 30
             return $this->validateAssetMin($this->existingAsset($value), $parameters);
31 31
         }
32 32
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     private function addCustomValidationMessage($attribute, $params, $validator): void
60 60
     {
61 61
         $validator->setCustomMessages([
62
-            'imagefield_min' => 'De :attribute is te klein en dient groter te zijn dan ' . implode(',', $params) . 'Kb.',
62
+            'imagefield_min' => 'De :attribute is te klein en dient groter te zijn dan '.implode(',', $params).'Kb.',
63 63
         ]);
64 64
 
65 65
         if (!isset($validator->customAttributes[$attribute])) {
Please login to merge, or discard this patch.
src/Fields/ValidationRules/ValidatesExistingAssetAttributes.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
     protected function refersToExistingAsset($value): bool
11 11
     {
12 12
         // Check if id is passed first
13
-        if(!preg_match('/^[1-9][0-9]*$/', $value)) return false;
13
+        if (!preg_match('/^[1-9][0-9]*$/', $value)) return false;
14 14
 
15 15
         return !is_null($this->existingAsset($value));
16 16
     }
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     {
36 36
         $filepath = $asset->media->first()->getPath();
37 37
 
38
-        if (! $sizeDetails = @getimagesize($filepath)) {
38
+        if (!$sizeDetails = @getimagesize($filepath)) {
39 39
             return false;
40 40
         }
41 41
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
     protected function refersToExistingAsset($value): bool
11 11
     {
12 12
         // Check if id is passed first
13
-        if(!preg_match('/^[1-9][0-9]*$/', $value)) return false;
13
+        if(!preg_match('/^[1-9][0-9]*$/', $value)) {
14
+            return false;
15
+        }
14 16
 
15 17
         return !is_null($this->existingAsset($value));
16 18
     }
Please login to merge, or discard this patch.
src/Fields/ValidationRules/ImageFieldMaxRule.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  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
 
17 17
                     $this->addCustomValidationMessage($attribute, $params, $validator);
18 18
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
     public function validateMax($attribute, $value, $parameters)
28 28
     {
29
-        if($this->refersToExistingAsset($value)) {
29
+        if ($this->refersToExistingAsset($value)) {
30 30
             return $this->validateAssetMax($this->existingAsset($value), $parameters);
31 31
         }
32 32
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     private function addCustomValidationMessage($attribute, $params, $validator): void
63 63
     {
64 64
         $validator->setCustomMessages([
65
-            'imagefield_max' => 'De :attribute is te groot en dient kleiner te zijn dan ' . implode(',', $params) . 'Kb.',
65
+            'imagefield_max' => 'De :attribute is te groot en dient kleiner te zijn dan '.implode(',', $params).'Kb.',
66 66
         ]);
67 67
 
68 68
         if (!isset($validator->customAttributes[$attribute])) {
Please login to merge, or discard this patch.
src/Fields/ValidationRules/FileFieldMaxRule.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
     {
12 12
         $value = $this->normalizePayload($value);
13 13
 
14
-        foreach([MediaRequest::NEW, MediaRequest::REPLACE] as $type) {
15
-            foreach($value[$type] as $file) {
16
-                if($file && false === $this->validateMax($attribute, $file, $params)) {
14
+        foreach ([MediaRequest::NEW, MediaRequest::REPLACE] as $type) {
15
+            foreach ($value[$type] as $file) {
16
+                if ($file && false === $this->validateMax($attribute, $file, $params)) {
17 17
                     $this->addCustomValidationMessage($attribute, $params, $validator);
18 18
                     return false;
19 19
                 }
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function validateMax($attribute, $value, $parameters)
27 27
     {
28
-        if($this->refersToExistingAsset($value)) {
28
+        if ($this->refersToExistingAsset($value)) {
29 29
             return $this->validateAssetMax($this->existingAsset($value), $parameters);
30 30
         }
31 31
 
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
      */
42 42
     protected function getSize($attribute, $value)
43 43
     {
44
-        if(!$value instanceof File) {
45
-            throw new \InvalidArgumentException('Value is expected to be of type ' . File::class);
44
+        if (!$value instanceof File) {
45
+            throw new \InvalidArgumentException('Value is expected to be of type '.File::class);
46 46
         }
47 47
 
48 48
         return $value->getSize() / 1024;
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     private function addCustomValidationMessage($attribute, $params, $validator): void
57 57
     {
58 58
         $validator->setCustomMessages([
59
-            'filefield_max' => 'De :attribute is te groot en dient kleiner te zijn dan ' . implode(',', $params) . 'Kb.',
59
+            'filefield_max' => 'De :attribute is te groot en dient kleiner te zijn dan '.implode(',', $params).'Kb.',
60 60
         ]);
61 61
 
62 62
         if (!isset($validator->customAttributes[$attribute])) {
Please login to merge, or discard this patch.