| Conditions | 4 |
| Paths | 3 |
| Total Lines | 25 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | public function passes($attribute, $value) |
||
| 32 | { |
||
| 33 | |||
| 34 | // TODO: Inject mocked Guzzle\Client to getDomainURL to test these responses here. |
||
| 35 | $result = Domain::getDomainURL($value); |
||
| 36 | // Domain is available with http:// or https:// |
||
| 37 | if (is_string($result)) { |
||
| 38 | return true; |
||
| 39 | } |
||
| 40 | |||
| 41 | // Domain is only available with or without www. |
||
| 42 | elseif (isset($result) && $result->isNotEmpty()) { |
||
| 43 | Log::info('Domain not available: '.$value); |
||
| 44 | Log::info('Alternative domain is available: '.$result['alternativeAvailable']); |
||
| 45 | |||
| 46 | $this->errorMessage = $result->get('notAvailable').' is not available. Did you mean '.$result->get('alternativeAvailable').'?'; |
||
| 47 | |||
| 48 | return false; |
||
| 49 | } |
||
| 50 | |||
| 51 | Log::info('Domain not available: '.$value); |
||
| 52 | |||
| 53 | $this->errorMessage = $value.' is not available.'; |
||
| 54 | |||
| 55 | return false; |
||
| 56 | } |
||
| 68 |