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.

Collection   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 92
rs 10
c 0
b 0
f 0
wmc 17

3 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 24 9
A parse() 0 21 6
A load() 0 9 2
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
}