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.

ChainProcedureLoader   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 86
c 0
b 0
f 0
wmc 8
lcom 1
cbo 0
ccs 20
cts 20
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addLoader() 0 4 1
A load() 0 17 3
A loadTemplate() 0 17 3
1
<?php
2
3
/*
4
 * This file is part of the php-phantomjs.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
namespace JonnyW\PhantomJs\Procedure;
10
11
/**
12
 * PHP PhantomJs
13
 *
14
 * @author Jon Wenmoth <[email protected]>
15
 */
16
class ChainProcedureLoader implements ProcedureLoaderInterface
17
{
18
    /**
19
     * Procedure loader storage.
20
     *
21
     * @var array
22
     * @access protected
23
     */
24
    protected $procedureLoaders;
25
26
    /**
27
     * Internal constructor.
28
     *
29
     * @access public
30
     * @param array $procedureLoaders
31
     */
32 6
    public function __construct(array $procedureLoaders)
33
    {
34 6
        $this->procedureLoaders = $procedureLoaders;
35 6
    }
36
37
    /**
38
     * Add procedure loader.
39
     *
40
     * @access public
41
     * @param  \JonnyW\PhantomJs\Procedure\ProcedureLoaderInterface $procedureLoader
42
     * @return void
43
     */
44 4
    public function addLoader(ProcedureLoaderInterface $procedureLoader)
45
    {
46 4
        array_unshift($this->procedureLoaders, $procedureLoader);
47 4
    }
48
49
    /**
50
     * Load procedure instance by id.
51
     *
52
     * @access public
53
     * @param  string                                         $id
54
     * @throws \InvalidArgumentException
55
     * @return \JonnyW\PhantomJs\Procedure\ProcedureInterface
56
     */
57 50
    public function load($id)
58
    {
59
        /** @var \JonnyW\PhantomJs\Procedure\ProcedureLoaderInterface $loader **/
60 50
        foreach ($this->procedureLoaders as $loader) {
61
62
            try {
63
64 49
                $procedure = $loader->load($id);
65
66 49
                return $procedure;
67
68 47
            } catch (\Exception $e) {}
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
69
70 48
        }
71
72 1
        throw new \InvalidArgumentException(sprintf('No valid procedure loader could be found to load the \'%s\' procedure.', $id));
73
    }
74
75
    /**
76
     * Load procedure template by id.
77
     *
78
     * @access public
79
     * @param  string                    $id
80
     * @param  string                    $extension (default: 'proc')
81
     * @throws \InvalidArgumentException
82
     * @return string
83
     */
84 7
    public function loadTemplate($id, $extension = 'proc')
85
    {
86
        /** @var \JonnyW\PhantomJs\Procedure\ProcedureLoaderInterface $loader **/
87 7
        foreach ($this->procedureLoaders as $loader) {
88
89
            try {
90
91 6
                $template = $loader->loadTemplate($id, $extension);
92
93 6
                return $template;
94
95 5
            } catch (\Exception $e) {}
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
96
97 6
        }
98
99 1
        throw new \InvalidArgumentException(sprintf('No valid procedure loader could be found to load the \'%s\' procedure template.', $id));
100
    }
101
}
102