Passed
Push — master ( e8b00c...89139c )
by Anton
07:46
created
src/Views/src/Engine/AbstractEngine.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
      */
45 45
     public function getLoader(): LoaderInterface
46 46
     {
47
-        if (empty($this->loader)) {
47
+        if (empty($this->loader)){
48 48
             throw new EngineException('No associated loader found');
49 49
         }
50 50
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,8 @@
 block discarded – undo
44 44
      */
45 45
     public function getLoader(): LoaderInterface
46 46
     {
47
-        if (empty($this->loader)) {
47
+        if (empty($this->loader))
48
+        {
48 49
             throw new EngineException('No associated loader found');
49 50
         }
50 51
 
Please login to merge, or discard this patch.
src/Views/src/Engine/Native/NativeView.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,21 +49,21 @@
 block discarded – undo
49 49
         ob_start();
50 50
         $__outputLevel__ = ob_get_level();
51 51
 
52
-        try {
52
+        try{
53 53
             ContainerScope::runScope($this->container, function () use ($data): void {
54 54
                 extract($data, EXTR_OVERWRITE);
55 55
                 // render view in context and output buffer scope, context can be accessed using $this->context
56 56
                 require $this->view->getFilename();
57 57
             });
58
-        } catch (\Throwable $e) {
59
-            while (ob_get_level() >= $__outputLevel__) {
58
+        }catch (\Throwable $e){
59
+            while (ob_get_level() >= $__outputLevel__){
60 60
                 ob_end_clean();
61 61
             }
62 62
 
63 63
             throw new RenderException($e);
64
-        } finally {
64
+        }finally{
65 65
             //Closing all nested buffers
66
-            while (ob_get_level() > $__outputLevel__) {
66
+            while (ob_get_level() > $__outputLevel__){
67 67
                 ob_end_clean();
68 68
             }
69 69
         }
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,21 +49,28 @@
 block discarded – undo
49 49
         ob_start();
50 50
         $__outputLevel__ = ob_get_level();
51 51
 
52
-        try {
52
+        try
53
+        {
53 54
             ContainerScope::runScope($this->container, function () use ($data): void {
54 55
                 extract($data, EXTR_OVERWRITE);
55 56
                 // render view in context and output buffer scope, context can be accessed using $this->context
56 57
                 require $this->view->getFilename();
57 58
             });
58
-        } catch (\Throwable $e) {
59
-            while (ob_get_level() >= $__outputLevel__) {
59
+        }
60
+        catch (\Throwable $e)
61
+        {
62
+            while (ob_get_level() >= $__outputLevel__)
63
+            {
60 64
                 ob_end_clean();
61 65
             }
62 66
 
63 67
             throw new RenderException($e);
64
-        } finally {
68
+        }
69
+        finally
70
+        {
65 71
             //Closing all nested buffers
66
-            while (ob_get_level() > $__outputLevel__) {
72
+            while (ob_get_level() > $__outputLevel__)
73
+            {
67 74
                 ob_end_clean();
68 75
             }
69 76
         }
Please login to merge, or discard this patch.
src/Views/src/ViewCache.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function reset(ContextInterface $context = null): void
25 25
     {
26
-        if (empty($context)) {
26
+        if (empty($context)){
27 27
             $this->cache = [];
28 28
             return;
29 29
         }
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function resetPath(string $path): void
40 40
     {
41
-        foreach ($this->cache as &$cache) {
41
+        foreach ($this->cache as &$cache){
42 42
             unset($cache[$path], $cache);
43 43
         }
44 44
     }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function get(ContextInterface $context, string $path): ViewInterface
74 74
     {
75
-        if (!$this->has($context, $path)) {
75
+        if (!$this->has($context, $path)){
76 76
             throw new CacheException("No cache is available for {$path}.");
77 77
         }
78 78
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,8 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function reset(ContextInterface $context = null): void
25 25
     {
26
-        if (empty($context)) {
26
+        if (empty($context))
27
+        {
27 28
             $this->cache = [];
28 29
             return;
29 30
         }
@@ -38,7 +39,8 @@  discard block
 block discarded – undo
38 39
      */
39 40
     public function resetPath(string $path): void
40 41
     {
41
-        foreach ($this->cache as &$cache) {
42
+        foreach ($this->cache as &$cache)
43
+        {
42 44
             unset($cache[$path], $cache);
43 45
         }
44 46
     }
@@ -72,7 +74,8 @@  discard block
 block discarded – undo
72 74
      */
73 75
     public function get(ContextInterface $context, string $path): ViewInterface
74 76
     {
75
-        if (!$this->has($context, $path)) {
77
+        if (!$this->has($context, $path))
78
+        {
76 79
             throw new CacheException("No cache is available for {$path}.");
77 80
         }
78 81
 
Please login to merge, or discard this patch.
src/Security/tests/PermissionManagerTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,8 +90,8 @@
 block discarded – undo
90 90
         $this->assertEquals($allowRule, $manager->getRule(static::ROLE, static::PERMISSION));
91 91
 
92 92
         // test pattern permission
93
-        $this->assertEquals($manager, $manager->associate(static::ROLE, static::PERMISSION . '.*', AllowRule::class));
94
-        $this->assertEquals($allowRule, $manager->getRule(static::ROLE, static::PERMISSION . '.' . static::PERMISSION));
93
+        $this->assertEquals($manager, $manager->associate(static::ROLE, static::PERMISSION.'.*', AllowRule::class));
94
+        $this->assertEquals($allowRule, $manager->getRule(static::ROLE, static::PERMISSION.'.'.static::PERMISSION));
95 95
 
96 96
         $this->assertEquals($manager, $manager->deassociate(static::ROLE, static::PERMISSION));
97 97
         $this->assertEquals($forbidRule, $manager->getRule(static::ROLE, static::PERMISSION));
Please login to merge, or discard this patch.
src/Security/tests/Traits/GuardedTraitTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
         $this->assertEquals(static::OPERATION, $guarded->resolvePermission(static::OPERATION));
101 101
 
102 102
         $guarded = new GuardedWithNamespace();
103
-        $resolvedPermission = GuardedWithNamespace::GUARD_NAMESPACE . '.' . static::OPERATION;
103
+        $resolvedPermission = GuardedWithNamespace::GUARD_NAMESPACE.'.'.static::OPERATION;
104 104
         $this->assertEquals($resolvedPermission, $guarded->resolvePermission(static::OPERATION));
105 105
     }
106 106
 }
Please login to merge, or discard this patch.
src/Security/tests/RuleManagerTest.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
         // other rule types
61 61
         $manager->set('RuleInterface', $this->rule);
62 62
         $this->assertEquals($this->rule, $manager->get('RuleInterface'));
63
-        $manager->set('Closure', function () {
63
+        $manager->set('Closure', function (){
64 64
             return true;
65 65
         });
66 66
         $this->assertTrue($manager->get('Closure') instanceof CallableRule);
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,8 @@
 block discarded – undo
60 60
         // other rule types
61 61
         $manager->set('RuleInterface', $this->rule);
62 62
         $this->assertEquals($this->rule, $manager->get('RuleInterface'));
63
-        $manager->set('Closure', function () {
63
+        $manager->set('Closure', function ()
64
+        {
64 65
             return true;
65 66
         });
66 67
         $this->assertTrue($manager->get('Closure') instanceof CallableRule);
Please login to merge, or discard this patch.
src/Security/src/PermissionManager.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function addRole(string $role): PermissionManager
74 74
     {
75
-        if ($this->hasRole($role)) {
75
+        if ($this->hasRole($role)){
76 76
             throw new RoleException("Role '{$role}' already exists");
77 77
         }
78 78
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function removeRole(string $role): PermissionManager
92 92
     {
93
-        if (!$this->hasRole($role)) {
93
+        if (!$this->hasRole($role)){
94 94
             throw new RoleException("Undefined role '{$role}'");
95 95
         }
96 96
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      */
113 113
     public function getPermissions(string $role): array
114 114
     {
115
-        if (!$this->hasRole($role)) {
115
+        if (!$this->hasRole($role)){
116 116
             throw new RoleException("Undefined role '{$role}'");
117 117
         }
118 118
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public function getRule(string $role, string $permission): RuleInterface
126 126
     {
127
-        if (!$this->hasRole($role)) {
127
+        if (!$this->hasRole($role)){
128 128
             throw new RoleException("Undefined role '{$role}'");
129 129
         }
130 130
 
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function associate(string $role, string $permission, string $rule = AllowRule::class): PermissionManager
141 141
     {
142
-        if (!$this->hasRole($role)) {
142
+        if (!$this->hasRole($role)){
143 143
             throw new RoleException("Undefined role '{$role}'");
144 144
         }
145 145
 
146
-        if (!$this->rules->has($rule)) {
146
+        if (!$this->rules->has($rule)){
147 147
             throw new PermissionException("Undefined rule '{$rule}'");
148 148
         }
149 149
 
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
      */
177 177
     private function findRule(string $role, string $permission): string
178 178
     {
179
-        if (isset($this->permissions[$role][$permission])) {
179
+        if (isset($this->permissions[$role][$permission])){
180 180
             //O(1) check
181 181
             return $this->permissions[$role][$permission];
182 182
         }
183 183
 
184 184
         //Matching using star syntax
185
-        foreach ($this->permissions[$role] as $pattern => $rule) {
186
-            if ($this->matcher->matches($permission, $pattern)) {
185
+        foreach ($this->permissions[$role] as $pattern => $rule){
186
+            if ($this->matcher->matches($permission, $pattern)){
187 187
                 return $rule;
188 188
             }
189 189
         }
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -72,7 +72,8 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function addRole(string $role): PermissionManager
74 74
     {
75
-        if ($this->hasRole($role)) {
75
+        if ($this->hasRole($role))
76
+        {
76 77
             throw new RoleException("Role '{$role}' already exists");
77 78
         }
78 79
 
@@ -90,7 +91,8 @@  discard block
 block discarded – undo
90 91
      */
91 92
     public function removeRole(string $role): PermissionManager
92 93
     {
93
-        if (!$this->hasRole($role)) {
94
+        if (!$this->hasRole($role))
95
+        {
94 96
             throw new RoleException("Undefined role '{$role}'");
95 97
         }
96 98
 
@@ -112,7 +114,8 @@  discard block
 block discarded – undo
112 114
      */
113 115
     public function getPermissions(string $role): array
114 116
     {
115
-        if (!$this->hasRole($role)) {
117
+        if (!$this->hasRole($role))
118
+        {
116 119
             throw new RoleException("Undefined role '{$role}'");
117 120
         }
118 121
 
@@ -124,7 +127,8 @@  discard block
 block discarded – undo
124 127
      */
125 128
     public function getRule(string $role, string $permission): RuleInterface
126 129
     {
127
-        if (!$this->hasRole($role)) {
130
+        if (!$this->hasRole($role))
131
+        {
128 132
             throw new RoleException("Undefined role '{$role}'");
129 133
         }
130 134
 
@@ -139,11 +143,13 @@  discard block
 block discarded – undo
139 143
      */
140 144
     public function associate(string $role, string $permission, string $rule = AllowRule::class): PermissionManager
141 145
     {
142
-        if (!$this->hasRole($role)) {
146
+        if (!$this->hasRole($role))
147
+        {
143 148
             throw new RoleException("Undefined role '{$role}'");
144 149
         }
145 150
 
146
-        if (!$this->rules->has($rule)) {
151
+        if (!$this->rules->has($rule))
152
+        {
147 153
             throw new PermissionException("Undefined rule '{$rule}'");
148 154
         }
149 155
 
@@ -176,14 +182,17 @@  discard block
 block discarded – undo
176 182
      */
177 183
     private function findRule(string $role, string $permission): string
178 184
     {
179
-        if (isset($this->permissions[$role][$permission])) {
185
+        if (isset($this->permissions[$role][$permission]))
186
+        {
180 187
             //O(1) check
181 188
             return $this->permissions[$role][$permission];
182 189
         }
183 190
 
184 191
         //Matching using star syntax
185
-        foreach ($this->permissions[$role] as $pattern => $rule) {
186
-            if ($this->matcher->matches($permission, $pattern)) {
192
+        foreach ($this->permissions[$role] as $pattern => $rule)
193
+        {
194
+            if ($this->matcher->matches($permission, $pattern))
195
+            {
187 196
                 return $rule;
188 197
             }
189 198
         }
Please login to merge, or discard this patch.
src/Security/src/Guard.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         PermissionsInterface $permissions,
37 37
         ActorInterface $actor = null,
38 38
         array $roles = []
39
-    ) {
39
+    ){
40 40
         $this->roles = $roles;
41 41
         $this->actor = $actor;
42 42
         $this->permissions = $permissions;
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
     public function allows(string $permission, array $context = []): bool
49 49
     {
50 50
         $allows = false;
51
-        foreach ($this->getRoles() as $role) {
52
-            if (!$this->permissions->hasRole($role)) {
51
+        foreach ($this->getRoles() as $role){
52
+            if (!$this->permissions->hasRole($role)){
53 53
                 continue;
54 54
             }
55 55
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function getActor(): ActorInterface
97 97
     {
98
-        if (empty($this->actor)) {
98
+        if (empty($this->actor)){
99 99
             throw new GuardException('Unable to get Guard Actor, no value set');
100 100
         }
101 101
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,8 +48,10 @@  discard block
 block discarded – undo
48 48
     public function allows(string $permission, array $context = []): bool
49 49
     {
50 50
         $allows = false;
51
-        foreach ($this->getRoles() as $role) {
52
-            if (!$this->permissions->hasRole($role)) {
51
+        foreach ($this->getRoles() as $role)
52
+        {
53
+            if (!$this->permissions->hasRole($role))
54
+            {
53 55
                 continue;
54 56
             }
55 57
 
@@ -95,7 +97,8 @@  discard block
 block discarded – undo
95 97
      */
96 98
     public function getActor(): ActorInterface
97 99
     {
98
-        if (empty($this->actor)) {
100
+        if (empty($this->actor))
101
+        {
99 102
             throw new GuardException('Unable to get Guard Actor, no value set');
100 103
         }
101 104
 
Please login to merge, or discard this patch.
src/Security/src/Matcher.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,10 +40,10 @@
 block discarded – undo
40 40
      */
41 41
     public function matches(string $string, string $pattern): bool
42 42
     {
43
-        if ($string === $pattern) {
43
+        if ($string === $pattern){
44 44
             return true;
45 45
         }
46
-        if (!$this->isPattern($pattern)) {
46
+        if (!$this->isPattern($pattern)){
47 47
             return false;
48 48
         }
49 49
         return (bool)preg_match($this->getRegex($pattern), $string);
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,10 +40,12 @@
 block discarded – undo
40 40
      */
41 41
     public function matches(string $string, string $pattern): bool
42 42
     {
43
-        if ($string === $pattern) {
43
+        if ($string === $pattern)
44
+        {
44 45
             return true;
45 46
         }
46
-        if (!$this->isPattern($pattern)) {
47
+        if (!$this->isPattern($pattern))
48
+        {
47 49
             return false;
48 50
         }
49 51
         return (bool)preg_match($this->getRegex($pattern), $string);
Please login to merge, or discard this patch.