GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( f9c1aa...ebbda5 )
by Steeven
19:04 queued 02:32
created

Collection::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 9
rs 10
c 0
b 0
f 0
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;
0 ignored issues
show
Bug introduced by
The type O2System\Spl\Patterns\St...ovider\AbstractProvider was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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
}