ControlsAccess::denyFrom()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace LaraCrafts\GeoRoutes\Concerns;
4
5
trait ControlsAccess
6
{
7
    /**
8
     * Determines whether to allow or deny access.
9
     *
10
     * @var string
11
     */
12
    protected $strategy;
13
14
    /**
15
     * The countries to apply the rule for.
16
     *
17
     * @var array
18
     */
19
    protected $countries;
20
21
    /**
22
     * Allow access from the given countries.
23
     *
24
     * @param string ...$countries
25
     *
26
     * @return $this
27
     */
28 112
    public function allowFrom(string ...$countries)
29
    {
30 112
        $this->strategy = 'allow';
31 112
        $this->countries = $countries;
32
33 112
        return $this;
34
    }
35
36
    /**
37
     * Deny access from the given countries.
38
     *
39
     * @param string ...$countries
40
     *
41
     * @return $this
42
     */
43
    public function denyFrom(string ...$countries)
44
    {
45
        $this->strategy = 'deny';
46
        $this->countries = $countries;
47
    }
48
49
    /**
50
     * Allow given countries.
51
     *
52
     * @return $this
53
     */
54
    public function allow()
55
    {
56
        $this->strategy = 'allow';
57
58
        return $this;
59
    }
60
61
    /**
62
     * Deny given countries.
63
     *
64
     * @return $this
65
     */
66
    public function deny()
67
    {
68
        $this->strategy = 'deny';
69
70
        return $this;
71
    }
72
}
73