ActionMiddlewareOptions::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace BrightComponents\Actions;
4
5
class ActionMiddlewareOptions
6
{
7
    /**
8
     * The middleware options.
9
     *
10
     * @var array
11
     */
12
    protected $options;
13
14
    /**
15
     * Create a new middleware option instance.
16
     *
17
     * @param  array  $options
18
     */
19
    public function __construct(array &$options)
20
    {
21
        $this->options = &$options;
22
    }
23
24
    /**
25
     * Set the controller methods the middleware should apply to.
26
     *
27
     * @param  array|string|dynamic  $methods
28
     *
29
     * @return $this
30
     */
31
    public function only($methods)
32
    {
33
        $this->options['only'] = is_array($methods) ? $methods : func_get_args();
34
35
        return $this;
36
    }
37
38
    /**
39
     * Set the controller methods the middleware should exclude.
40
     *
41
     * @param  array|string|dynamic  $methods
42
     *
43
     * @return $this
44
     */
45
    public function except($methods)
46
    {
47
        $this->options['except'] = is_array($methods) ? $methods : func_get_args();
48
49
        return $this;
50
    }
51
}
52