| Conditions | 3 |
| Paths | 3 |
| Total Lines | 94 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 59 | public function validate($role, Constraint $constraint) |
||
| 60 | { |
||
| 61 | $validator = new Validator; |
||
| 62 | $property = ' |
||
| 63 | { |
||
| 64 | "type": "array", |
||
| 65 | "items": { |
||
| 66 | "type": "array", |
||
| 67 | "additionalProperties": false, |
||
| 68 | "required": ["scope", "permissions"], |
||
| 69 | "properties": { |
||
| 70 | "scope": { |
||
| 71 | "type": "array", |
||
| 72 | "additionalProperties": false, |
||
| 73 | "properties": { |
||
| 74 | "operator": { |
||
| 75 | "type": "string", |
||
| 76 | "enum": ["and", "or"] |
||
| 77 | }, |
||
| 78 | "conditions": { |
||
| 79 | "type": "array" |
||
| 80 | }, |
||
| 81 | "type": { |
||
| 82 | "type": "string", |
||
| 83 | "enum": ["generic", "object", "identity", "owner", "session", "property"] |
||
| 84 | }, |
||
| 85 | "entity": { |
||
| 86 | "type": "string" |
||
| 87 | }, |
||
| 88 | "entity_uuid": { |
||
| 89 | "type": ["string", "null"] |
||
| 90 | }, |
||
| 91 | "property": { |
||
| 92 | "type": "string" |
||
| 93 | }, |
||
| 94 | "comparison": { |
||
| 95 | "type": "string", |
||
| 96 | "enum": ["eq", "neq", "like"] |
||
| 97 | }, |
||
| 98 | "value": {} |
||
| 99 | } |
||
| 100 | }, |
||
| 101 | "permissions": { |
||
| 102 | "type": "array", |
||
| 103 | "items": { |
||
| 104 | "type": "array", |
||
| 105 | "additionalProperties": false, |
||
| 106 | "required": ["key", "attributes"], |
||
| 107 | "properties": { |
||
| 108 | "key": { |
||
| 109 | "type": "string" |
||
| 110 | }, |
||
| 111 | "attributes": { |
||
| 112 | "type": "array", |
||
| 113 | "items": { |
||
| 114 | "type": "string", |
||
| 115 | "enum": ["BROWSE", "READ", "EDIT", "ADD", "DELETE", "EXECUTE"] |
||
| 116 | } |
||
| 117 | } |
||
| 118 | } |
||
| 119 | } |
||
| 120 | } |
||
| 121 | } |
||
| 122 | } |
||
| 123 | } |
||
| 124 | '; |
||
| 125 | $schema = json_decode(' |
||
| 126 | { |
||
| 127 | "type": "array", |
||
| 128 | "additionalProperties": false, |
||
| 129 | "properties": { |
||
| 130 | "assets": ' . $property . ', |
||
| 131 | "authentication": ' . $property . ', |
||
| 132 | "cases": ' . $property . ', |
||
| 133 | "cms": ' . $property . ', |
||
| 134 | "forms": ' . $property . ', |
||
| 135 | "identities": ' . $property . ', |
||
| 136 | "microservice": ' . $property . ', |
||
| 137 | "records": ' . $property . ', |
||
| 138 | "services": ' . $property . ', |
||
| 139 | "tasks": ' . $property . ', |
||
| 140 | "tenants": ' . $property . ' |
||
| 141 | } |
||
| 142 | } |
||
| 143 | '); |
||
| 144 | $permissions = $role->getPermissions(); |
||
| 145 | $validator->validate($permissions, $schema); |
||
| 146 | |||
| 147 | if (!$validator->isValid()) { |
||
| 148 | foreach ($validator->getErrors() as $error) { |
||
| 149 | $this->context |
||
| 150 | ->buildViolation($error['message']) |
||
| 151 | ->atPath('permissions.' . $error['property']) |
||
| 152 | ->addViolation(); |
||
| 153 | } |
||
| 157 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths