Completed
Pull Request — 2.0 (#75)
by Julien
02:03
created

InspectorPooler   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 2 Features 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 51
c 2
b 2
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPoolerType() 0 4 1
A getClient() 0 8 2
A createClient() 0 15 2
1
<?php
2
/*
3
 * This file is part of the Pomm package.
4
 *
5
 * (c) 2014 - 2015 Grégoire HUBERT <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PommProject\Foundation\Inspector;
11
12
use PommProject\Foundation\Client\ClientPooler;
13
use PommProject\Foundation\Client\ClientPoolerInterface;
14
use PommProject\Foundation\Exception\FoundationException;
15
16
/**
17
 * InspectorPooler
18
 *
19
 * Pooler for Inspector client.
20
 *
21
 * @package   Foundation
22
 * @copyright 2014 - 2015 Grégoire HUBERT
23
 * @author    Grégoire HUBERT
24
 * @license   X11 {@link http://opensource.org/licenses/mit-license.php}
25
 * @see       ClientPooler
26
 */
27
class InspectorPooler extends ClientPooler
28
{
29
    /**
30
     * getPoolerType
31
     *
32
     * @see ClientPoolerInterface
33
     */
34
    public function getPoolerType()
35
    {
36
        return 'inspector';
37
    }
38
39
    /**
40
     * getClient
41
     *
42
     * @see     ClientPooler
43
     * @param null|string $identifier
44
     * @return Inspector
45
     */
46
    public function getClient($identifier = null)
47
    {
48
        if ($identifier === null) {
49
            $identifier = '\PommProject\Foundation\Inspector\Inspector';
50
        }
51
52
        return parent::getClient($identifier);
53
    }
54
55
    /**
56
     * createClient
57
     *
58
     * @see    ClientPooler
59
     * @return Inspector
60
     * @throws FoundationException
61
     */
62
    protected function createClient($identifier)
63
    {
64
        try {
65
            new \ReflectionClass($identifier);
66
        } catch (\ReflectionException $e) {
67
            throw new FoundationException(
68
                sprintf(
69
                    "Unable to load inspector '%s'.",
70
                    $identifier
71
                )
72
            );
73
        }
74
75
        return new $identifier();
76
    }
77
}
78