1 | <?php |
||
14 | final class Factory |
||
15 | { |
||
16 | private static $instance = null; |
||
17 | 2 | public static function getInstance() |
|
21 | |||
22 | 1 | private function __construct() |
|
26 | |||
27 | /** |
||
28 | * don't need Authorization |
||
29 | * @var array { |
||
30 | * 'origin.example.com' => x |
||
31 | * } |
||
32 | */ |
||
33 | private $connections = array(); |
||
|
|||
34 | |||
35 | /** |
||
36 | * need Authorization header |
||
37 | * @var array { |
||
38 | * 'origin.example.com' => x |
||
39 | * } |
||
40 | */ |
||
41 | private $authConnections = array(); |
||
42 | |||
43 | /** |
||
44 | * get cached curl handler |
||
45 | * @param string $origin |
||
46 | * @param bool $auth |
||
47 | * @return resource<curl> |
||
48 | */ |
||
49 | 1 | public static function getConnection($origin, $auth=false) |
|
50 | { |
||
51 | 1 | $instance = self::getInstance(); |
|
52 | 1 | if ($auth) { |
|
53 | 1 | if (isset($instance->authConnections[$origin])) { |
|
54 | 1 | return $instance->authConnections[$origin]; |
|
55 | } |
||
56 | |||
57 | 1 | return $instance->authConnections[$origin] = curl_init(); |
|
58 | } else { |
||
59 | 1 | if (isset($instance->connections[$origin])) { |
|
60 | 1 | return $instance->connections[$origin]; |
|
61 | } |
||
62 | |||
63 | 1 | return $instance->connections[$origin] = curl_init(); |
|
64 | } |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @return Aspects\JoinPoint |
||
69 | */ |
||
70 | 1 | public static function getPreEvent(Aspects\HttpGetRequest $req) |
|
78 | |||
79 | /** |
||
80 | * @return Aspects\JoinPoint |
||
81 | */ |
||
82 | 1 | public static function getPostEvent(Aspects\HttpGetRequest $req) |
|
88 | |||
89 | /** |
||
90 | * @return Aspects\AspectAuth (same instance) |
||
91 | */ |
||
92 | 2 | public static function getAspectAuth() |
|
97 | } |
||
98 |
This check marks private properties in classes that are never used. Those properties can be removed.