Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
26 / 26
100.00% covered (success)
100.00%
18 / 18
87.50% covered (warning)
87.50%
14 / 16
100.00% covered (success)
100.00%
13 / 13
CRAP
100.00% covered (success)
100.00%
1 / 1
HookCollection
100.00% covered (success)
100.00%
26 / 26
100.00% covered (success)
100.00%
18 / 18
87.50% covered (warning)
87.50%
14 / 16
100.00% covered (success)
100.00%
13 / 13
17.56
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
3
 offsetExists
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 offsetGet
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 offsetSet
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 offsetUnset
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 exists
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __call
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
6 / 6
50.00% covered (danger)
50.00%
2 / 4
100.00% covered (success)
100.00%
1 / 1
4.12
 count
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 rewind
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 next
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 current
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 valid
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 key
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php namespace GorillaClaw;
2
3class HookCollection implements \ArrayAccess, \Countable, \Iterator {
4    protected array $wp_filter;
5    protected array $callbacks;
6
7    function __construct(array $wp_filter) {
8        $this->wp_filter = $wp_filter;
9
10        $collect = [];
11
12        array_walk($this->wp_filter, function($entry, $hook_name) use (&$collect) {
13            foreach($entry as $priority => $callbacks) {
14                foreach($callbacks as $function_key => $callback) {
15                    $collect[] = new Hook($hook_name, $callback, $priority, $function_key);
16                }
17            }
18        });
19        
20        $this->callbacks = $collect;
21    }
22
23    public function offsetExists(mixed $offset): bool {
24        return isset($this->callbacks[$offset]);
25    }
26
27    public function offsetGet(mixed $offset): mixed {
28        return $this->callbacks[$offset];
29    }
30
31    public function offsetSet(mixed $offset, mixed $value): void {
32        $this->callbacks[$offset] = $value;
33    }
34
35    public function offsetUnset(mixed $offset): void {
36        unset($this->callbacks[$offset]);
37    }
38
39    public function exists() {
40        return count($this->callbacks) > 0;
41    }
42
43    function __call($prop, $args) {
44        $prohibit = ['rebind'];
45        $ret = [];
46        
47        if(in_array($prop, $prohibit)) {
48            throw new \ErrorException("Cannot rebind from a HookCollection");
49        }
50
51        foreach($this->callbacks as $hook) {
52            $ret[$hook->function_key] = $hook->$prop(...$args);
53        }
54
55        return $ret;
56    }
57
58    public function count(): int {
59        return count($this->callbacks);
60    }
61
62
63    public function rewind(): void {
64        reset($this->callbacks);
65    }
66
67
68    public function next(): void {
69        next($this->callbacks);
70    }
71
72    #[\ReturnTypeWillChange]
73    public function current(): Hook {
74        return current($this->callbacks);
75    }
76
77
78    public function valid(): bool {
79        return key($this->callbacks) !== null;
80    }
81
82    #[\ReturnTypeWillChange]
83    public function key(): int {
84        return key($this->callbacks);
85    }
86}

Branches

Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once. Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

HookCollection->__call
43    function __call($prop, $args) {
44        $prohibit = ['rebind'];
45        $ret = [];
46        
47        if(in_array($prop, $prohibit)) {
48            throw new \ErrorException("Cannot rebind from a HookCollection");
51        foreach($this->callbacks as $hook) {
51        foreach($this->callbacks as $hook) {
51        foreach($this->callbacks as $hook) {
52            $ret[$hook->function_key] = $hook->$prop(...$args);
51        foreach($this->callbacks as $hook) {
52            $ret[$hook->function_key] = $hook->$prop(...$args);
53        }
54
55        return $ret;
56    }
HookCollection->__construct
7    function __construct(array $wp_filter) {
8        $this->wp_filter = $wp_filter;
9
10        $collect = [];
11
12        array_walk($this->wp_filter, function($entry, $hook_name) use (&$collect) {
13            foreach($entry as $priority => $callbacks) {
14                foreach($callbacks as $function_key => $callback) {
15                    $collect[] = new Hook($hook_name, $callback, $priority, $function_key);
16                }
17            }
18        });
19        
20        $this->callbacks = $collect;
21    }
HookCollection->count
59        return count($this->callbacks);
60    }
HookCollection->current
74        return current($this->callbacks);
75    }
HookCollection->exists
40        return count($this->callbacks) > 0;
41    }
HookCollection->key
84        return key($this->callbacks);
85    }
HookCollection->next
69        next($this->callbacks);
70    }
HookCollection->offsetExists
23    public function offsetExists(mixed $offset): bool {
24        return isset($this->callbacks[$offset]);
25    }
HookCollection->offsetGet
27    public function offsetGet(mixed $offset): mixed {
28        return $this->callbacks[$offset];
29    }
HookCollection->offsetSet
31    public function offsetSet(mixed $offset, mixed $value): void {
32        $this->callbacks[$offset] = $value;
33    }
HookCollection->offsetUnset
35    public function offsetUnset(mixed $offset): void {
36        unset($this->callbacks[$offset]);
37    }
HookCollection->rewind
64        reset($this->callbacks);
65    }
HookCollection->valid
79        return key($this->callbacks) !== null;
80    }
GorillaClaw\{closure:/home/runner/work/gorilla-claw/gorilla-claw/src/class/HookCollection.php:12-18}
12        array_walk($this->wp_filter, function($entry, $hook_name) use (&$collect) {
13            foreach($entry as $priority => $callbacks) {
13            foreach($entry as $priority => $callbacks) {
13            foreach($entry as $priority => $callbacks) {
14                foreach($callbacks as $function_key => $callback) {
14                foreach($callbacks as $function_key => $callback) {
14                foreach($callbacks as $function_key => $callback) {
13            foreach($entry as $priority => $callbacks) {
14                foreach($callbacks as $function_key => $callback) {
13            foreach($entry as $priority => $callbacks) {
14                foreach($callbacks as $function_key => $callback) {
15                    $collect[] = new Hook($hook_name, $callback, $priority, $function_key);
16                }
17            }
18        });