| Conditions | 7 |
| Paths | 7 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 7 |
| Changes | 0 | ||
| 1 | <?php |
||
| 56 | 8 | public function removeCallbackWithPriority($priority = 10, $callback = '') |
|
| 57 | { |
||
| 58 | 8 | $hooks = $this->getHooks(); |
|
| 59 | 8 | if (isset($hooks[$priority]) == true) { |
|
|
|
|||
| 60 | 8 | $callbacks = $hooks[$priority]; |
|
| 61 | 8 | foreach ($callbacks as $index => $entry) { |
|
| 62 | 8 | if ($entry['callback'] == $callback) { |
|
| 63 | 8 | unset($this->hooks[$priority][$index]); |
|
| 64 | |||
| 65 | 8 | if (count($this->hooks[$priority]) > 0) { |
|
| 66 | 4 | $new = []; |
|
| 67 | 4 | foreach ($this->hooks[$priority] as $hook) { |
|
| 68 | 4 | $new[] = $hook; |
|
| 69 | 2 | } |
|
| 70 | 4 | $this->hooks[$priority] = $new; |
|
| 71 | 6 | } elseif (count($this->hooks[$priority]) == 0) { |
|
| 72 | 6 | unset($this->hooks[$priority]); |
|
| 73 | 2 | } |
|
| 74 | 4 | } |
|
| 75 | 4 | } |
|
| 76 | 4 | } |
|
| 77 | 8 | } |
|
| 78 | |||
| 87 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.