Passed
Push — 0.7.0 ( e442b6...679d5f )
by Alexander
11:21 queued 12s
created

ControllerMiddlewareOptions   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 47
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A except() 0 5 2
A __construct() 0 3 1
A only() 0 5 2
1
<?php
2
3
/**
4
 * Lenevor Framework
5
 *
6
 * LICENSE
7
 *
8
 * This source file is subject to the new BSD license that is bundled
9
 * with this package in the file license.md.
10
 * It is also available through the world-wide-web at this URL:
11
 * https://lenevor.com/license
12
 * If you did not receive a copy of the license and are unable to
13
 * obtain it through the world-wide-web, please send an email
14
 * to [email protected] so we can send you a copy immediately.
15
 *
16
 * @package     Lenevor
17
 * @subpackage  Base
18
 * @link        https://lenevor.com
19
 * @copyright   Copyright (c) 2019 - 2021 Alexander Campo <[email protected]>
20
 * @license     https://opensource.org/licenses/BSD-3-Clause New BSD license or see https://lenevor.com/license or see /license.md
21
 */
22
 
23
namespace Syscodes\Controller;
24
25
/**
26
 * This class allows to include or exclude methods of a given class 
27
 * to executed middlewares. 
28
 * 
29
 * @author Alexander Campo <[email protected]>
30
 */
31
class ControllerMiddlewareOptions
32
{
33
    /**
34
     * The middleware options.
35
     * 
36
     * @var array $options
37
     */
38
    protected $options;
39
    
40
    /**
41
     * Constructor. Create a new middleware option instance.
42
     * 
43
     * @param  array  $options
44
     * 
45
     * @return void
46
     */
47
    public function __construct(array &$options)
48
    {
49
        $this->options = &$options;
50
    }
51
    
52
    /**
53
     * Set the controller methods the middleware should apply to.
54
     * 
55
     * @param  array|string|dynamic  $methods
0 ignored issues
show
Bug introduced by
The type Syscodes\Controller\dynamic was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
56
     * 
57
     * @return $this
58
     */
59
    public function only($methods)
60
    {
61
        $this->options['only'] = is_array($methods) ? $methods : func_get_args();
62
        
63
        return $this;
64
    }
65
    
66
    /**
67
     * Set the controller methods the middleware should exclude.
68
     * 
69
     * @param  array|string|dynamic  $methods
70
     * 
71
     * @return $this
72
     */
73
    public function except($methods)
74
    {
75
        $this->options['except'] = is_array($methods) ? $methods : func_get_args();
76
        
77
        return $this;
78
    }
79
}
80