| Conditions | 11 |
| Paths | 19 |
| Total Lines | 33 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 45 | public function matchObjectStateGroup($conditions) |
||
| 46 | { |
||
| 47 | $this->validateConditions($conditions); |
||
| 48 | |||
| 49 | foreach ($conditions as $key => $values) { |
||
| 50 | |||
| 51 | if (!is_array($values)) { |
||
| 52 | $values = array($values); |
||
| 53 | } |
||
| 54 | |||
| 55 | switch ($key) { |
||
| 56 | case 'id': |
||
| 57 | case self::MATCH_OBJECTSTATEGROUP_ID: |
||
| 58 | return new ObjectStateGroupCollection($this->findObjectStateGroupsById($values)); |
||
| 59 | |||
| 60 | case 'identifier': |
||
| 61 | case self::MATCH_OBJECTSTATEGROUP_IDENTIFIER: |
||
| 62 | return new ObjectStateGroupCollection($this->findObjectStateGroupsByIdentifier($values)); |
||
| 63 | |||
| 64 | case self::MATCH_ALL: |
||
| 65 | return new ObjectStateGroupCollection($this->findAllObjectStateGroups()); |
||
| 66 | |||
| 67 | case self::MATCH_AND: |
||
| 68 | return $this->matchAnd($values); |
||
|
|
|||
| 69 | |||
| 70 | case self::MATCH_OR: |
||
| 71 | return $this->matchOr($values); |
||
| 72 | |||
| 73 | case self::MATCH_NOT: |
||
| 74 | return new ObjectStateGroupCollection(array_diff_key($this->findAllObjectStateGroups(), $this->matchObjectStateGroup($values)->getArrayCopy())); |
||
| 75 | } |
||
| 76 | } |
||
| 77 | } |
||
| 78 | |||
| 140 |