1 | <?php |
||
17 | final class Factory |
||
18 | { |
||
19 | /** |
||
20 | * not need Authorization |
||
21 | * @var array { |
||
22 | * 'origin.example.com' => x |
||
23 | * } |
||
24 | */ |
||
25 | private static $connections = array(); |
||
26 | |||
27 | /** |
||
28 | * need Authorization header |
||
29 | * @var array { |
||
30 | * 'origin.example.com' => x |
||
31 | * } |
||
32 | */ |
||
33 | private static $authConnections = array(); |
||
34 | |||
35 | /** |
||
36 | * get cached curl handler |
||
37 | * @param string $origin |
||
38 | * @param bool $auth |
||
39 | * @return resource<curl> |
||
|
|||
40 | */ |
||
41 | 7 | public static function getConnection($origin, $auth = false) |
|
57 | |||
58 | /** |
||
59 | * @param string $origin domain text |
||
60 | * @param string $url |
||
61 | * @param IO\IOInterface $io |
||
62 | * @param CConfig $config |
||
63 | * @param array $pluginConfig |
||
64 | * @return Aspects\HttpGetRequest |
||
65 | */ |
||
66 | 9 | public static function getHttpGetRequest($origin, $url, IO\IOInterface $io, CConfig $config, array $pluginConfig) |
|
67 | { |
||
68 | 9 | if (substr($origin, -10) === 'github.com') { |
|
69 | 1 | $origin = 'github.com'; |
|
70 | 1 | $requestClass = 'GitHub'; |
|
71 | 9 | } elseif (in_array($origin, $config->get('github-domains') ?: array())) { |
|
72 | 1 | $requestClass = 'GitHub'; |
|
73 | 9 | } elseif (in_array($origin, $config->get('gitlab-domains') ?: array())) { |
|
74 | 1 | $requestClass = 'GitLab'; |
|
75 | 1 | } else { |
|
76 | 8 | $requestClass = 'HttpGet'; |
|
77 | } |
||
78 | 9 | $requestClass = __NAMESPACE__ . '\Aspects\\' . $requestClass . 'Request'; |
|
79 | 9 | $request = new $requestClass($origin, $url, $io); |
|
80 | 9 | $request->verbose = $pluginConfig['verbose']; |
|
81 | 9 | if ($pluginConfig['insecure']) { |
|
82 | 1 | $request->curlOpts[CURLOPT_SSL_VERIFYPEER] = false; |
|
83 | 1 | } |
|
84 | 9 | if (!empty($pluginConfig['cainfo'])) { |
|
85 | 1 | $request->curlOpts[CURLOPT_CAINFO] = $pluginConfig['cainfo']; |
|
86 | 1 | } |
|
87 | 9 | if (!empty($pluginConfig['userAgent'])) { |
|
88 | 1 | $request->curlOpts[CURLOPT_USERAGENT] = $pluginConfig['userAgent']; |
|
89 | 1 | } |
|
90 | 9 | return $request; |
|
91 | } |
||
92 | |||
93 | /** |
||
94 | * @return Aspects\JoinPoint |
||
95 | */ |
||
96 | 9 | public static function getPreEvent(Aspects\HttpGetRequest $req) |
|
104 | |||
105 | /** |
||
106 | * @return Aspects\JoinPoint |
||
107 | */ |
||
108 | 7 | public static function getPostEvent(Aspects\HttpGetRequest $req) |
|
114 | |||
115 | /** |
||
116 | * @return Aspects\AspectAuth (same instance) |
||
117 | */ |
||
118 | 10 | public static function getAspectAuth() |
|
123 | } |
||
124 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.