Passed
Push — master ( 74d060...d17a79 )
by Kirill
05:31 queued 10s
created
src/Framework/Validation/Checker/EntityChecker.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
     public function exists($value, string $role, ?string $field = null, bool $ignoreCase = false): bool
43 43
     {
44 44
         $repository = $this->orm->getRepository($role);
45
-        if ($field === null) {
45
+        if ($field === null){
46 46
             return $repository->findByPK($value) !== null;
47 47
         }
48 48
 
49
-        if ($ignoreCase && is_string($value) && $repository instanceof Repository) {
49
+        if ($ignoreCase && is_string($value) && $repository instanceof Repository){
50 50
             return $this
51 51
                 ->getCaseInsensitiveSelect($repository, $field, $value)
52 52
                 ->fetchOne() !== null;
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
         $values = $this->withValues($withFields);
69 69
         $values[$field] = $value;
70 70
 
71
-        if ($this->isProvidedByContext($role, $values)) {
71
+        if ($this->isProvidedByContext($role, $values)){
72 72
             return true;
73 73
         }
74 74
 
75 75
         $repository = $this->orm->getRepository($role);
76 76
 
77
-        if ($ignoreCase && is_string($value) && $repository instanceof Repository) {
77
+        if ($ignoreCase && is_string($value) && $repository instanceof Repository){
78 78
             return $this
79 79
                 ->getCaseInsensitiveSelect($repository, $field, $value)
80 80
                 ->fetchOne() === null;
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
     private function withValues(array $fields): array
91 91
     {
92 92
         $values = [];
93
-        foreach ($fields as $field) {
94
-            if ($this->getValidator()->hasValue($field)) {
93
+        foreach ($fields as $field){
94
+            if ($this->getValidator()->hasValue($field)){
95 95
                 $values[$field] = $this->getValidator()->getValue($field);
96 96
             }
97 97
         }
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
     private function isProvidedByContext(string $role, array $values): bool
108 108
     {
109 109
         $entity = $this->getValidator()->getContext();
110
-        if (!is_object($entity) || !$this->orm->getHeap()->has($entity)) {
110
+        if (!is_object($entity) || !$this->orm->getHeap()->has($entity)){
111 111
             return false;
112 112
         }
113 113
 
114 114
         $extract = $this->orm->getMapper($role)->extract($entity);
115
-        foreach ($values as $field => $value) {
116
-            if (!isset($extract[$field]) || $extract[$field] !== $value) {
115
+        foreach ($values as $field => $value){
116
+            if (!isset($extract[$field]) || $extract[$field] !== $value){
117 117
                 return false;
118 118
             }
119 119
         }
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -42,11 +42,13 @@  discard block
 block discarded – undo
42 42
     public function exists($value, string $role, ?string $field = null, bool $ignoreCase = false): bool
43 43
     {
44 44
         $repository = $this->orm->getRepository($role);
45
-        if ($field === null) {
45
+        if ($field === null)
46
+        {
46 47
             return $repository->findByPK($value) !== null;
47 48
         }
48 49
 
49
-        if ($ignoreCase && is_string($value) && $repository instanceof Repository) {
50
+        if ($ignoreCase && is_string($value) && $repository instanceof Repository)
51
+        {
50 52
             return $this
51 53
                 ->getCaseInsensitiveSelect($repository, $field, $value)
52 54
                 ->fetchOne() !== null;
@@ -68,13 +70,15 @@  discard block
 block discarded – undo
68 70
         $values = $this->withValues($withFields);
69 71
         $values[$field] = $value;
70 72
 
71
-        if ($this->isProvidedByContext($role, $values)) {
73
+        if ($this->isProvidedByContext($role, $values))
74
+        {
72 75
             return true;
73 76
         }
74 77
 
75 78
         $repository = $this->orm->getRepository($role);
76 79
 
77
-        if ($ignoreCase && is_string($value) && $repository instanceof Repository) {
80
+        if ($ignoreCase && is_string($value) && $repository instanceof Repository)
81
+        {
78 82
             return $this
79 83
                 ->getCaseInsensitiveSelect($repository, $field, $value)
80 84
                 ->fetchOne() === null;
@@ -90,8 +94,10 @@  discard block
 block discarded – undo
90 94
     private function withValues(array $fields): array
91 95
     {
92 96
         $values = [];
93
-        foreach ($fields as $field) {
94
-            if ($this->getValidator()->hasValue($field)) {
97
+        foreach ($fields as $field)
98
+        {
99
+            if ($this->getValidator()->hasValue($field))
100
+            {
95 101
                 $values[$field] = $this->getValidator()->getValue($field);
96 102
             }
97 103
         }
@@ -107,13 +113,16 @@  discard block
 block discarded – undo
107 113
     private function isProvidedByContext(string $role, array $values): bool
108 114
     {
109 115
         $entity = $this->getValidator()->getContext();
110
-        if (!is_object($entity) || !$this->orm->getHeap()->has($entity)) {
116
+        if (!is_object($entity) || !$this->orm->getHeap()->has($entity))
117
+        {
111 118
             return false;
112 119
         }
113 120
 
114 121
         $extract = $this->orm->getMapper($role)->extract($entity);
115
-        foreach ($values as $field => $value) {
116
-            if (!isset($extract[$field]) || $extract[$field] !== $value) {
122
+        foreach ($values as $field => $value)
123
+        {
124
+            if (!isset($extract[$field]) || $extract[$field] !== $value)
125
+            {
117 126
                 return false;
118 127
             }
119 128
         }
Please login to merge, or discard this patch.
tests/Framework/Validation/EntityCheckerTest.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@
 block discarded – undo
165 165
             ['value' => $value] + $data,
166 166
             ['value' => [['entity::unique', User::class, $field, $fields, $ignoreCase]]]
167 167
         );
168
-        if ($context !== null) {
168
+        if ($context !== null){
169 169
             $validator = $validator->withContext($context);
170 170
         }
171 171
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -165,7 +165,8 @@
 block discarded – undo
165 165
             ['value' => $value] + $data,
166 166
             ['value' => [['entity::unique', User::class, $field, $fields, $ignoreCase]]]
167 167
         );
168
-        if ($context !== null) {
168
+        if ($context !== null)
169
+        {
169 170
             $validator = $validator->withContext($context);
170 171
         }
171 172
 
Please login to merge, or discard this patch.