1 | <?php |
||
14 | class GsuiteChecker |
||
15 | { |
||
16 | /** @var array The domains */ |
||
17 | protected $domains = []; |
||
18 | |||
19 | /** @var null|Client */ |
||
20 | protected $httpClient = null; |
||
21 | |||
22 | /** @var int Pool Concurrency. Default: 25 */ |
||
23 | protected $concurrency = 25; |
||
24 | |||
25 | /** @var int Connection Timeout. Default: 5 seconds */ |
||
26 | protected $connectTimeout = 5; |
||
27 | |||
28 | /** |
||
29 | * Create a new instance of GsuiteChecker with provided domains. |
||
30 | * |
||
31 | * @param mixed $domains |
||
32 | */ |
||
33 | public function __construct($domains = []) |
||
37 | |||
38 | /** |
||
39 | * Create a new instance if the value isn't one already. |
||
40 | * |
||
41 | * @param mixed $domains |
||
42 | * |
||
43 | * @return static |
||
44 | */ |
||
45 | public static function make($domains = []) |
||
49 | |||
50 | /** |
||
51 | * Check whether the domain(s) have a Google Suite account associated with them. |
||
52 | * |
||
53 | * @return $this |
||
54 | */ |
||
55 | public function check() |
||
66 | |||
67 | /** |
||
68 | * Get all promises. |
||
69 | * |
||
70 | * @return Generator |
||
71 | */ |
||
72 | protected function getPromises() |
||
80 | |||
81 | /** |
||
82 | * Get HTTP Client. |
||
83 | * |
||
84 | * @return Client |
||
85 | */ |
||
86 | protected function getHttpClient() |
||
99 | |||
100 | /** |
||
101 | * Default User Agent. |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | protected function defaultUA() |
||
109 | |||
110 | /** |
||
111 | * Get all of the domains. |
||
112 | * |
||
113 | * @return array |
||
114 | */ |
||
115 | public function all() |
||
119 | |||
120 | /** |
||
121 | * Handle Response and Update Status of Domains. |
||
122 | * |
||
123 | * @param ResponseInterface|RequestException $response |
||
124 | * @param $index |
||
125 | */ |
||
126 | public function responseHandler($response, $index) |
||
140 | |||
141 | /** |
||
142 | * Determine status of GSuite based on response body. |
||
143 | * |
||
144 | * @param ResponseInterface|RequestException $response |
||
145 | * |
||
146 | * @return int |
||
147 | */ |
||
148 | protected function status($response) |
||
156 | |||
157 | /** |
||
158 | * Determine if a given string contains a given substring. |
||
159 | * |
||
160 | * @param string $haystack |
||
161 | * @param string|array $needles |
||
162 | * |
||
163 | * @return bool |
||
164 | */ |
||
165 | protected function strContains($haystack, $needles) |
||
175 | } |
||
176 |