Completed
Push — master ( 8a81d1...032cb3 )
by Alexey
02:10
created
src/Validations/IntValidation.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@
 block discarded – undo
23 23
     }
24 24
 
25 25
     protected function isIntValue($value){
26
-        if(is_bool($value)) return false;
26
+        if(is_bool($value)) {
27
+            return false;
28
+        }
27 29
         return  is_int($value) || preg_match('/^\d+$/',$value);
28 30
     }
29 31
 }
30 32
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@
 block discarded – undo
10 10
 {
11 11
     public function validate(ValueObject $data)
12 12
     {
13
-        if(! $this->isIntValue($data->value())) {
13
+        if (!$this->isIntValue($data->value())) {
14 14
             $this->error = "{$data->name()} must be integer";
15 15
             return false;
16 16
         }
17 17
         return true;
18 18
     }
19 19
 
20
-    protected function isIntValue($value){
21
-        if(is_bool($value)) return false;
22
-        return  is_int($value) || preg_match('/^\d+$/',$value);
20
+    protected function isIntValue($value) {
21
+        if (is_bool($value)) return false;
22
+        return  is_int($value) || preg_match('/^\d+$/', $value);
23 23
     }
24 24
 }
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
src/Validations/ValidationFactory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@
 block discarded – undo
27 27
      * @param $validation
28 28
      * @return ValidationInterface
29 29
      */
30
-    public function get($validation){
30
+    public function get($validation) {
31 31
         $options = explode(':', $validation);
32 32
         $validationName = array_shift($options);
33
-        if(!array_key_exists($validationName, $this->map)){
34
-            throw new InvalidValidationNameException('unknowk validation name '. $validationName);
33
+        if (!array_key_exists($validationName, $this->map)) {
34
+            throw new InvalidValidationNameException('unknowk validation name '.$validationName);
35 35
         }
36 36
         return new $this->map[$validationName]($options);
37 37
     }
Please login to merge, or discard this patch.
src/Validations/AbstractValidation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
         $this->options = $options;
14 14
     }
15 15
 
16
-    public function error(){
16
+    public function error() {
17 17
         return $this->error;
18 18
     }
19 19
 
Please login to merge, or discard this patch.
src/Validations/EmailValidation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
     public function validate(ValueObject $data)
12 12
     {
13 13
 
14
-        if(! $this->isEmail($data->value())) {
14
+        if (!$this->isEmail($data->value())) {
15 15
             $this->error = "incorrect email address in {$data->name()}";
16 16
             return false;
17 17
         }
Please login to merge, or discard this patch.
src/Validations/MaxValidation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 {
11 11
     public function validate(ValueObject $data)
12 12
     {
13
-        if(mb_strlen($data->value()) > $this->options[0]) {
13
+        if (mb_strlen($data->value()) > $this->options[0]) {
14 14
             $this->error = "{$data->name()} is too long (maximum {$this->options[0]} characters";
15 15
             return false;
16 16
         }
Please login to merge, or discard this patch.
src/Validations/RequiredValidation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 {
12 12
     public function validate(ValueObject $data)
13 13
     {
14
-        if($data instanceof NullValueObject) {
14
+        if ($data instanceof NullValueObject) {
15 15
             $this->error = "{$data->name()} must be specified";
16 16
             return false;
17 17
         }
Please login to merge, or discard this patch.
src/ValidationResult.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@
 block discarded – undo
17 17
         $this->errors = $errors;
18 18
     }
19 19
 
20
-    public function success(){
20
+    public function success() {
21 21
         return $this->result;
22 22
     }
23 23
 
24
-    public function fails(){
25
-        return ! $this->success();
24
+    public function fails() {
25
+        return !$this->success();
26 26
     }
27 27
 
28
-    public function data(){
28
+    public function data() {
29 29
         return $this->validated;
30 30
     }
31 31
 
32
-    public function errors(){
32
+    public function errors() {
33 33
         return $this->errors;
34 34
     }
35 35
 
Please login to merge, or discard this patch.
src/DataProvider.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
         $this->data = $data;
15 15
     }
16 16
 
17
-    public function get($key){
18
-        if(preg_match("/^(\S*)\s*as\s*(\S*)$/",$key, $matches)){
17
+    public function get($key) {
18
+        if (preg_match("/^(\S*)\s*as\s*(\S*)$/", $key, $matches)) {
19 19
             $name = $matches[1];
20 20
             $alias = $matches[2];
21 21
         } else {
22 22
             $name = $key;
23 23
             $alias = $key;
24 24
         }
25
-        if(!isset($this->data[$name])) return new NullValueObject($name, null);
25
+        if (!isset($this->data[$name])) return new NullValueObject($name, null);
26 26
 
27 27
         $value = new ValueObject($name, $this->data[$name]);
28 28
         $value->setAlias($alias);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@
 block discarded – undo
22 22
             $name = $key;
23 23
             $alias = $key;
24 24
         }
25
-        if(!isset($this->data[$name])) return new NullValueObject($name, null);
25
+        if(!isset($this->data[$name])) {
26
+            return new NullValueObject($name, null);
27
+        }
26 28
 
27 29
         $value = new ValueObject($name, $this->data[$name]);
28 30
         $value->setAlias($alias);
Please login to merge, or discard this patch.
src/ValueObject.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
         $this->name = $name;
27 27
         $this->alias = $name;
28 28
         $this->value = $value;
29
-        if(!in_array($type, $this->types())) throw new ValueObjectInvalidTypeException('Wrong type: '. $type);
29
+        if (!in_array($type, $this->types())) throw new ValueObjectInvalidTypeException('Wrong type: '.$type);
30 30
         $this->type = $type;
31 31
     }
32 32
 
33
-    public function setAlias($alias){
33
+    public function setAlias($alias) {
34 34
         $this->alias = $alias;
35 35
     }
36 36
 
37
-    protected function setName($name){
38
-        if(preg_match("/^(\S*)\s*as\s*(\S*)$/",$name, $matches)){
37
+    protected function setName($name) {
38
+        if (preg_match("/^(\S*)\s*as\s*(\S*)$/", $name, $matches)) {
39 39
             $this->name = $matches[1];
40 40
             $this->alias = $matches[2];
41 41
         } else {
@@ -46,52 +46,52 @@  discard block
 block discarded – undo
46 46
     }
47 47
 
48 48
 
49
-    public function __invoke(){
49
+    public function __invoke() {
50 50
         return $this->value;
51 51
     }
52 52
 
53
-    public function name(){
53
+    public function name() {
54 54
         return $this->name;
55 55
     }
56 56
 
57
-    public function alias(){
57
+    public function alias() {
58 58
         return $this->alias;
59 59
     }
60 60
 
61
-    public function value(){
61
+    public function value() {
62 62
         return $this->value;
63 63
     }
64 64
 
65
-    public function type(){
65
+    public function type() {
66 66
         return $this->type;
67 67
     }
68 68
 
69
-    public function isInt(){
69
+    public function isInt() {
70 70
         return $this->type === self::INT;
71 71
     }
72 72
 
73 73
 
74
-    public function isString(){
74
+    public function isString() {
75 75
         return $this->type === self::STRING;
76 76
     }
77 77
 
78
-    public function isBool(){
78
+    public function isBool() {
79 79
         return $this->type === self::BOOL;
80 80
     }
81 81
 
82
-    public function isFloat(){
82
+    public function isFloat() {
83 83
         return $this->type === self::FLOAT;
84 84
     }
85 85
 
86
-    public function isUndefinedType(){
86
+    public function isUndefinedType() {
87 87
         return is_null($this->type);
88 88
     }
89 89
 
90
-    protected function types(){
90
+    protected function types() {
91 91
         return [null, self::BOOL, self::FLOAT, self::INT, self::STRING];
92 92
     }
93 93
 
94
-    public static function get($value, $type = null){
94
+    public static function get($value, $type = null) {
95 95
         return new static($value, $type);
96 96
     }
97 97
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@
 block discarded – undo
26 26
         $this->name = $name;
27 27
         $this->alias = $name;
28 28
         $this->value = $value;
29
-        if(!in_array($type, $this->types())) throw new ValueObjectInvalidTypeException('Wrong type: '. $type);
29
+        if(!in_array($type, $this->types())) {
30
+            throw new ValueObjectInvalidTypeException('Wrong type: '. $type);
31
+        }
30 32
         $this->type = $type;
31 33
     }
32 34
 
Please login to merge, or discard this patch.