Completed
Push — master ( 0ad6a3...1975e6 )
by richard
03:59
created
src/Validators/Types/FileType.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     /**
86 86
      * Gets the value of unit.
87 87
      *
88
-     * @return mixed
88
+     * @return string
89 89
      */
90 90
     public function getUnit()
91 91
     {
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     /**
110 110
      * Gets the value of permissions.
111 111
      *
112
-     * @return mixed
112
+     * @return string
113 113
      */
114 114
     public function getPermissions()
115 115
     {
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
     /**
144 144
      * Sets the value of size.
145 145
      *
146
-     * @param mixed $size the size
146
+     * @param integer $size the size
147 147
      *
148 148
      * @return self
149 149
      */
Please login to merge, or discard this patch.
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@  discard block
 block discarded – undo
5 5
 use Almendra\Validators\Interfaces\TypeInterface;
6 6
 
7 7
 /**
8
-  * Abstracts a file.
9
-  */
10
- class FileType extends Type implements TypeInterface
11
- {
12
-     /**
13
-     * @var string Default size unit
14
-     */
8
+ * Abstracts a file.
9
+ */
10
+    class FileType extends Type implements TypeInterface
11
+    {
12
+        /**
13
+         * @var string Default size unit
14
+         */
15 15
     protected $unit = 'b';
16 16
 
17 17
     /**
@@ -33,54 +33,54 @@  discard block
 block discarded – undo
33 33
         'gb' => 1000000,
34 34
         ];
35 35
 
36
-     public function __construct($value)
37
-     {
38
-         parent::__construct($value);
36
+        public function __construct($value)
37
+        {
38
+            parent::__construct($value);
39 39
 
40
-         $this->setSize(filesize($this->getValue()[0]));
41
-         $this->setValid(true);
42
-     }
40
+            $this->setSize(filesize($this->getValue()[0]));
41
+            $this->setValid(true);
42
+        }
43 43
 
44
-     public function checkType($value)
45
-     {
46
-         return is_file($value);
47
-     }
44
+        public function checkType($value)
45
+        {
46
+            return is_file($value);
47
+        }
48 48
 
49
-     protected function toUnit($size, $unit = null)
50
-     {
51
-         if (!$unit) {
52
-             $unit = $this->getUnit();
53
-         }
49
+        protected function toUnit($size, $unit = null)
50
+        {
51
+            if (!$unit) {
52
+                $unit = $this->getUnit();
53
+            }
54 54
 
55
-         return $size = $size * ($this->unitInBytes[$unit]);
56
-     }
55
+            return $size = $size * ($this->unitInBytes[$unit]);
56
+        }
57 57
 
58
-     public function minSize($size, $unit = null)
59
-     {
60
-         $size = $this->toUnit($size, $unit);
58
+        public function minSize($size, $unit = null)
59
+        {
60
+            $size = $this->toUnit($size, $unit);
61 61
 
62
-         if ($this->getSize() < $size) {
63
-             $this->setValid(false);
64
-         }
62
+            if ($this->getSize() < $size) {
63
+                $this->setValid(false);
64
+            }
65 65
 
66
-         return $this;
67
-     }
66
+            return $this;
67
+        }
68 68
 
69
-     public function maxSize($size, $unit = null)
70
-     {
71
-         $size = $this->toUnit($size, $unit);
69
+        public function maxSize($size, $unit = null)
70
+        {
71
+            $size = $this->toUnit($size, $unit);
72 72
 
73
-         if ($this->getSize() > $size) {
74
-             $this->setValid(false);
75
-         }
73
+            if ($this->getSize() > $size) {
74
+                $this->setValid(false);
75
+            }
76 76
 
77
-         return $this;
78
-     }
77
+            return $this;
78
+        }
79 79
 
80
-     public function validate()
81
-     {
82
-         return $this->getValid();
83
-     }
80
+        public function validate()
81
+        {
82
+            return $this->getValid();
83
+        }
84 84
 
85 85
     /**
86 86
      * Gets the value of unit.
@@ -153,4 +153,4 @@  discard block
 block discarded – undo
153 153
 
154 154
         return $this;
155 155
     }
156
- }
156
+    }
Please login to merge, or discard this patch.
src/Validators/Types/PrimitiveType.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@  discard block
 block discarded – undo
6 6
 use Almendra\Validators\Interfaces\ComparisonInterface;
7 7
 
8 8
 /**
9
-  * Abstracts a primitive type and the operations related to it.
10
-  */
11
- abstract class PrimitiveType extends Type implements TypeInterface, ComparisonInterface
12
- {
13
-     public function compare($limit, $operator, $modifier = null)
14
-     {
15
-         $result = $this->inArray(
9
+ * Abstracts a primitive type and the operations related to it.
10
+ */
11
+    abstract class PrimitiveType extends Type implements TypeInterface, ComparisonInterface
12
+    {
13
+        public function compare($limit, $operator, $modifier = null)
14
+        {
15
+            $result = $this->inArray(
16 16
             $this->getValue(),
17 17
             $limit,
18 18
             function ($value, $limit) use ($operator, $modifier) {
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
                 return true;
28 28
             }, true);
29 29
 
30
-         return $result;
31
-     }
30
+            return $result;
31
+        }
32 32
 
33 33
     /**
34 34
      * Is the value type the same of this object?
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
         // @todo attempts to determinate it's own type
51 51
     }
52 52
 
53
-     public function validate()
54
-     {
55
-         return $this->getValid();
56
-     }
57
- }
53
+        public function validate()
54
+        {
55
+            return $this->getValid();
56
+        }
57
+    }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
          $result = $this->inArray(
16 16
             $this->getValue(),
17 17
             $limit,
18
-            function ($value, $limit) use ($operator, $modifier) {
18
+            function($value, $limit) use ($operator, $modifier) {
19 19
                 if ($modifier) {
20 20
                     $value = $modifier($value);
21 21
                 }
Please login to merge, or discard this patch.
src/Validators/Types/FloatType.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@
 block discarded – undo
7 7
 use Almendra\Validators\Traits\NumericalComparisonsTrait;
8 8
 
9 9
 /**
10
-  * Abstracts a float type.
11
-  */
12
- class FloatType extends PrimitiveType implements TypeInterface, ComparisonInterface
13
- {
14
-     use NumericalComparisonsTrait;
10
+ * Abstracts a float type.
11
+ */
12
+    class FloatType extends PrimitiveType implements TypeInterface, ComparisonInterface
13
+    {
14
+        use NumericalComparisonsTrait;
15 15
 
16
-     protected $name = 'float';
17
- }
16
+        protected $name = 'float';
17
+    }
Please login to merge, or discard this patch.
src/Validators/Types/DoubleType.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@
 block discarded – undo
7 7
 use Almendra\Validators\Traits\NumericalComparisonsTrait;
8 8
 
9 9
 /**
10
-  * Abstracts a float type.
11
-  */
12
- class DoubleType extends PrimitiveType implements TypeInterface, ComparisonInterface
13
- {
14
-     use NumericalComparisonsTrait;
10
+ * Abstracts a float type.
11
+ */
12
+    class DoubleType extends PrimitiveType implements TypeInterface, ComparisonInterface
13
+    {
14
+        use NumericalComparisonsTrait;
15 15
 
16
-     protected $name = 'double';
17
- }
16
+        protected $name = 'double';
17
+    }
Please login to merge, or discard this patch.
src/Validators/Types/StringType.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -6,30 +6,30 @@
 block discarded – undo
6 6
 use Almendra\Validators\Interfaces\ComparisonInterface;
7 7
 
8 8
 /**
9
-  * Abstracts a string type.
10
-  */
11
- class StringType extends PrimitiveType implements TypeInterface, ComparisonInterface
12
- {
13
-     protected $name = 'string';
14
-
15
-     public function min($limit)
16
-     {
17
-         $result = $this->compare($limit, '<', 'strlen');
18
-         $this->setValid($result);
19
-
20
-         return $this;
21
-     }
22
-
23
-     public function max($limit)
24
-     {
25
-         $result = $this->compare($limit, '>', 'strlen');
26
-         $this->setValid($result);
27
-
28
-         return $this;
29
-     }
30
-
31
-     public function range($left, $right)
32
-     {
33
-         return $this->min($left)->max($right);
34
-     }
35
- }
9
+ * Abstracts a string type.
10
+ */
11
+    class StringType extends PrimitiveType implements TypeInterface, ComparisonInterface
12
+    {
13
+        protected $name = 'string';
14
+
15
+        public function min($limit)
16
+        {
17
+            $result = $this->compare($limit, '<', 'strlen');
18
+            $this->setValid($result);
19
+
20
+            return $this;
21
+        }
22
+
23
+        public function max($limit)
24
+        {
25
+            $result = $this->compare($limit, '>', 'strlen');
26
+            $this->setValid($result);
27
+
28
+            return $this;
29
+        }
30
+
31
+        public function range($left, $right)
32
+        {
33
+            return $this->min($left)->max($right);
34
+        }
35
+    }
Please login to merge, or discard this patch.
src/Validators/Types/Type.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@  discard block
 block discarded – undo
6 6
 use Almendra\Validators\Traits\ArrayTrait;
7 7
 
8 8
 /**
9
-  * Abstracts a type.
10
-  */
11
- abstract class Type implements TypeInterface
12
- {
13
-     use ArrayTrait;
9
+ * Abstracts a type.
10
+ */
11
+    abstract class Type implements TypeInterface
12
+    {
13
+        use ArrayTrait;
14 14
 
15 15
     /**
16 16
      * @var string The type's name
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
      */
28 28
     protected $value;
29 29
 
30
-     public function __construct($value)
31
-     {
32
-         if (!$this->isValid($value)) {
33
-             throw new \InvalidArgumentException('Type is not valid.');
34
-         }
30
+        public function __construct($value)
31
+        {
32
+            if (!$this->isValid($value)) {
33
+                throw new \InvalidArgumentException('Type is not valid.');
34
+            }
35 35
 
36
-         $this->setValue($value);
37
-     }
36
+            $this->setValue($value);
37
+        }
38 38
 
39 39
     /**
40 40
      * Is the value a valid one?
@@ -129,4 +129,4 @@  discard block
 block discarded – undo
129 129
 
130 130
         return $this;
131 131
     }
132
- }
132
+    }
Please login to merge, or discard this patch.
src/Validators/Types/IntegerType.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@
 block discarded – undo
7 7
 use Almendra\Validators\Traits\NumericalComparisonsTrait;
8 8
 
9 9
 /**
10
-  * Abstracts an integer type.
11
-  */
12
- class IntegerType extends PrimitiveType implements TypeInterface, ComparisonInterface
13
- {
14
-     use NumericalComparisonsTrait;
10
+ * Abstracts an integer type.
11
+ */
12
+    class IntegerType extends PrimitiveType implements TypeInterface, ComparisonInterface
13
+    {
14
+        use NumericalComparisonsTrait;
15 15
 
16
-     protected $name = 'integer';
17
- }
16
+        protected $name = 'integer';
17
+    }
Please login to merge, or discard this patch.