| Conditions | 10 |
| Paths | 22 |
| Total Lines | 37 |
| Code Lines | 30 |
| 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 |
||
| 76 | protected function assert($value, $operator, $expected) |
||
| 77 | { |
||
| 78 | $businessEntity = null; |
||
| 79 | if ($this->currentViewHelper->getCurrentView() instanceof BusinessPage) { |
||
| 80 | $businessEntity = $this->currentViewHelper->getCurrentView()->getEntity(); |
||
| 81 | } |
||
| 82 | $result = false; |
||
| 83 | switch ($operator) { |
||
| 84 | case self::OPERAND_EQUAL: |
||
| 85 | $result = $value === $expected; |
||
| 86 | break; |
||
| 87 | case self::OPERAND_TRUE: |
||
| 88 | $result = $value == true; |
||
| 89 | break; |
||
| 90 | case self::OPERAND_FALSE: |
||
| 91 | $result = $value == false; |
||
| 92 | break; |
||
| 93 | case self::OPERAND_IN: |
||
| 94 | $result = in_array($value, unserialize($expected)); |
||
| 95 | break; |
||
| 96 | case self::IS_GRANTED: |
||
| 97 | case self::IS_NOT_GRANTED: |
||
| 98 | if (!$this->authorizationChecker->isGranted('ROLE_VICTOIRE')) { |
||
| 99 | $granted = $this->authorizationChecker->isGranted($expected, $businessEntity); |
||
| 100 | if ($operator === self::IS_GRANTED) { |
||
| 101 | $result = $granted; |
||
| 102 | } else { |
||
| 103 | $result = (false === $granted); |
||
| 104 | } |
||
| 105 | } else { |
||
| 106 | $result = true; |
||
| 107 | } |
||
| 108 | break; |
||
| 109 | } |
||
| 110 | |||
| 111 | return $result; |
||
| 112 | } |
||
| 113 | } |
||
| 114 |