Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
recursive_event_filter_iterator | |
0.00% |
0 / 22 |
|
0.00% |
0 / 3 |
306 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getChildren | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
accept | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
240 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | namespace phpbb\event; |
15 | |
16 | /** |
17 | * This filter ignores directories and files starting with a dot. |
18 | * It also skips some directories that do not contain events anyway, |
19 | * such as e.g. files/, store/ and vendor/ |
20 | */ |
21 | class recursive_event_filter_iterator extends \RecursiveFilterIterator |
22 | { |
23 | protected $root_path; |
24 | |
25 | /** |
26 | * Construct |
27 | * |
28 | * @param \RecursiveIterator $iterator |
29 | * @param string $root_path |
30 | */ |
31 | public function __construct(\RecursiveIterator $iterator, $root_path) |
32 | { |
33 | $this->root_path = str_replace(DIRECTORY_SEPARATOR, '/', $root_path); |
34 | parent::__construct($iterator); |
35 | } |
36 | |
37 | /** |
38 | * Return the inner iterator's children contained in a recursive_event_filter_iterator |
39 | * |
40 | * @return recursive_event_filter_iterator |
41 | */ |
42 | public function getChildren(): ?\RecursiveFilterIterator |
43 | { |
44 | $inner_iterator = $this->getInnerIterator(); |
45 | assert($inner_iterator instanceof \RecursiveIterator); |
46 | return new self($inner_iterator->getChildren(), $this->root_path); |
47 | } |
48 | |
49 | /** |
50 | * {@inheritDoc} |
51 | */ |
52 | public function accept(): bool |
53 | { |
54 | $relative_path = str_replace(DIRECTORY_SEPARATOR, '/', $this->current()); |
55 | $filename = $this->current()->getFilename(); |
56 | |
57 | return (substr($relative_path, -4) === '.php' || $this->current()->isDir()) |
58 | && $filename[0] !== '.' |
59 | && strpos($relative_path, $this->root_path . 'cache/') !== 0 |
60 | && strpos($relative_path, $this->root_path . 'develop/') !== 0 |
61 | && strpos($relative_path, $this->root_path . 'docs/') !== 0 |
62 | && strpos($relative_path, $this->root_path . 'ext/') !== 0 |
63 | && strpos($relative_path, $this->root_path . 'files/') !== 0 |
64 | && strpos($relative_path, $this->root_path . 'includes/utf/') !== 0 |
65 | && strpos($relative_path, $this->root_path . 'language/') !== 0 |
66 | && strpos($relative_path, $this->root_path . 'phpbb/db/migration/data/') !== 0 |
67 | && strpos($relative_path, $this->root_path . 'phpbb/event/') !== 0 |
68 | && strpos($relative_path, $this->root_path . 'store/') !== 0 |
69 | && strpos($relative_path, $this->root_path . 'tests/') !== 0 |
70 | && strpos($relative_path, $this->root_path . 'vendor/') !== 0 |
71 | ; |
72 | } |
73 | } |