RouteResourceTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 55
ccs 6
cts 6
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getResourceId() 0 4 1
A resource() 0 4 1
A privilege() 0 4 1
extras() 0 1 ?
1
<?php
2
/**
3
 * Cheka - Authorization
4
 *
5
 * PHP version 5
6
 *
7
 * Copyright (C) 2016 Jake Johns
8
 *
9
 * This software may be modified and distributed under the terms
10
 * of the MIT license.  See the LICENSE file for details.
11
 *
12
 * @category  Router
13
 * @package   Jnjxp\Cheka
14
 * @author    Jake Johns <[email protected]>
15
 * @copyright 2016 Jake Johns
16
 * @license   http://jnj.mit-license.org/2016 MIT License
17
 * @link      https://github.com/jnjxp/jnjxp.cheka
18
 */
19
20
namespace Jnjxp\Cheka\Route;
21
22
use Jnjxp\Cheka\ResourceRouteAwareTrait;
23
24
/**
25
 * Route resource trait
26
 *
27
 * @category Route
28
 * @package  Jnjxp\Cheka
29
 * @author   Jake Johns <[email protected]>
30
 * @license  http://jnj.mit-license.org/ MIT License
31
 * @link     https://github.com/jnjxp/jnjxp.cheka
32
 */
33
trait RouteResourceTrait
34
{
35
    use ResourceRouteAwareTrait;
36
37
    /**
38
     * Get resourceId
39
     *
40
     * @return string|null
41
     *
42
     * @access public
43
     */
44 1
    public function getResourceId()
45
    {
46 1
        return $this->getResourceIdFromRoute($this);
47
    }
48
49
    /**
50
     * Set resourceId extra key
51
     *
52
     * @param string $resource resourceId
53
     *
54
     * @return $this
55
     *
56
     * @access public
57
     */
58 2
    public function resource($resource)
59
    {
60 2
        return $this->extras([$this->resourceIdKey => $resource]);
61
    }
62
63
    /**
64
     * Set privilege string
65
     *
66
     * @param string $privilege privilege to require
67
     *
68
     * @return $this
69
     *
70
     * @access public
71
     */
72 2
    public function privilege($privilege)
73
    {
74 2
        return $this->extras([$this->privilegeKey => $privilege]);
75
    }
76
77
    /**
78
     * Provided by BaseRoute classes
79
     *
80
     * @param array $extras array of extras
81
     *
82
     * @return $this
83
     *
84
     * @access public
85
     */
86
    abstract public function extras(array $extras);
87
}
88