Completed
Pull Request — master (#22)
by
unknown
02:30
created

Custom   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A provider() 0 4 1
A regionAvailable() 0 4 1
A validate() 0 14 4
1
<?php
2
3
namespace Laravel\Forge\Servers\Providers;
4
5
use InvalidArgumentException;
6
7
class Custom extends Provider
8
{
9
    /**
10
     * @{inheritdoc}
11
     */
12
    public function provider()
13
    {
14
        return 'custom';
15
    }
16
17
    /**
18
     * @{inheritdoc}
19
     */
20
    public function regionAvailable(string $region)
21
    {
22
        throw new InvalidArgumentException('Custom provider does not support any region.');
23
    }
24
25
    /**
26
     * @{inheritdoc}
27
     */
28
    public function validate()
29
    {
30
        $errors = [];
31
32
        if (empty($this->payload['ip_address'])) {
33
            $errors[] = 'ip_address';
34
        }
35
36
        if (empty($this->payload['private_ip_address'])) {
37
            $errors[] = 'private_ip_address';
38
        }
39
40
        return count($errors) > 0 ? $errors : true;
41
    }
42
}
43