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

InspectorPooler::createClient()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 9
nc 2
nop 1
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