Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| factory | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| get | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 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\finder; |
| 15 | |
| 16 | use phpbb\cache\service; |
| 17 | |
| 18 | /** |
| 19 | * The finder provides a simple way to locate files in the core and a set of extensions |
| 20 | */ |
| 21 | class factory |
| 22 | { |
| 23 | protected $cache; |
| 24 | protected $use_cache; |
| 25 | protected $phpbb_root_path; |
| 26 | protected $php_ext; |
| 27 | |
| 28 | /** |
| 29 | * Creates a new finder instance with its dependencies |
| 30 | * |
| 31 | * @param service|null $cache A cache instance or null |
| 32 | * @param bool $use_cache Use cache or not |
| 33 | * @param string $phpbb_root_path Path to the phpbb root directory |
| 34 | * @param string $php_ext php file extension |
| 35 | */ |
| 36 | public function __construct(service|null $cache, bool $use_cache, string $phpbb_root_path, string $php_ext) |
| 37 | { |
| 38 | $this->cache = $cache; |
| 39 | $this->use_cache = $use_cache; |
| 40 | $this->phpbb_root_path = $phpbb_root_path; |
| 41 | $this->php_ext = $php_ext; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * The cache variable name used to store $this->cached_queries in $this->cache. |
| 46 | * |
| 47 | * Allows the use of multiple differently configured finders with the same cache. |
| 48 | * |
| 49 | * @param string $cache_name The name of the cache variable, defaults to _ext_finder |
| 50 | * @return finder New instance of finder |
| 51 | */ |
| 52 | public function get(string $cache_name = '_ext_finder'): finder |
| 53 | { |
| 54 | return new finder($this->cache, $this->use_cache, $this->phpbb_root_path, $this->php_ext, $cache_name); |
| 55 | } |
| 56 | } |