1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the O2System Framework package. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
* |
8
|
|
|
* @author Steeve Andrian Salim |
9
|
|
|
* @copyright Copyright (c) Steeve Andrian Salim |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
// ------------------------------------------------------------------------ |
13
|
|
|
|
14
|
|
|
namespace O2System\Parser\String; |
15
|
|
|
|
16
|
|
|
// ------------------------------------------------------------------------ |
17
|
|
|
|
18
|
|
|
use O2System\Spl\Patterns\Structural\Provider\AbstractProvider; |
|
|
|
|
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class Collection |
22
|
|
|
* @package O2System\Parser\String |
23
|
|
|
*/ |
24
|
|
|
class Collection extends AbstractProvider |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Collection::$supportedAdapters |
28
|
|
|
* |
29
|
|
|
* @var array |
30
|
|
|
*/ |
31
|
|
|
public $supportedAdapters = [ |
32
|
|
|
|
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
// ------------------------------------------------------------------------ |
36
|
|
|
|
37
|
|
|
public function __construct() |
38
|
|
|
{ |
39
|
|
|
if ($handle = opendir(__DIR__ . DIRECTORY_SEPARATOR . 'Adapters')) { |
40
|
|
|
|
41
|
|
|
while (false !== ($file = readdir($handle))) { |
42
|
|
|
|
43
|
|
|
if ($file != "." && $file != "..") { |
44
|
|
|
array_push($this->supportedAdapters, pathinfo($file, PATHINFO_FILENAME)); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
closedir($handle); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
if ($handle = opendir(__DIR__ . DIRECTORY_SEPARATOR . 'Engines')) { |
52
|
|
|
|
53
|
|
|
while (false !== ($file = readdir($handle))) { |
54
|
|
|
|
55
|
|
|
if ($file != "." && $file != "..") { |
56
|
|
|
array_push($this->supportedAdapters, pathinfo($file, PATHINFO_FILENAME)); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
closedir($handle); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
// ------------------------------------------------------------------------ |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Collection::load |
68
|
|
|
* |
69
|
|
|
* @param string $engine |
70
|
|
|
* @param array $config |
71
|
|
|
* |
72
|
|
|
* @return bool |
73
|
|
|
*/ |
74
|
|
|
public function load($engine, array $config = []) |
75
|
|
|
{ |
76
|
|
|
if(class_exists($adapter = '\O2System\Parser\String\Adapters\\' . $engine)) { |
77
|
|
|
$this->register((new $adapter())->setConfig($config), $adapter); |
78
|
|
|
|
79
|
|
|
return $this->__isset($adapter); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return false; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
// ------------------------------------------------------------------------ |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Collection::parse |
89
|
|
|
* |
90
|
|
|
* @param string $string |
91
|
|
|
* @param array $vars |
92
|
|
|
* |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
|
|
public function parse($string, array $vars = []) |
96
|
|
|
{ |
97
|
|
|
$output = $string; |
98
|
|
|
|
99
|
|
|
if(is_file($string)) { |
100
|
|
|
$output = file_get_contents($string); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
if($this->count()) { |
104
|
|
|
foreach($this->registry as $adapter) { |
105
|
|
|
if($adapter instanceof Abstracts\AbstractAdapter) { |
106
|
|
|
if($adapter->isSupported()) { |
107
|
|
|
$adapter->initialize(); |
108
|
|
|
$adapter->loadString($output); |
109
|
|
|
$output = $adapter->parse($vars); |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
return $output; |
116
|
|
|
} |
117
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths