Completed
Push — master ( f12285...016462 )
by Anton
09:53 queued 07:39
created

Item::getTarget()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
9
namespace Spiral\Vault\Models;
10
11
use Spiral\Core\Component;
12
use Spiral\Translator\Traits\TranslatorTrait;
13
use Spiral\Vault\Vault;
14
15
class Item extends Component
16
{
17
    use TranslatorTrait;
18
19
    /**
20
     * @var Vault
21
     */
22
    private $vault;
23
24
    /**
25
     * @var string
26
     */
27
    private $target = '';
28
29
    /**
30
     * @var array
31
     */
32
    private $item = [
33
        'title'    => '',
34
        'badge'    => '',
35
        'requires' => '',
36
    ];
37
38
    /**
39
     * @param string $target
40
     * @param array  $options
41
     */
42
    public function __construct(Vault $vault, string $target, array $options)
43
    {
44
        $this->vault = $vault;
45
        $this->target = $target;
46
        $this->item = $options;
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function getTarget(): string
53
    {
54
        return $this->target;
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    public function getTitle(): string
61
    {
62
        return $this->say($this->item['title']);
63
    }
64
65
    /**
66
     * Check if item is visible.
67
     *
68
     * @return bool
69
     */
70
    public function isVisible(): bool
71
    {
72
        return $this->vault->getGuard()->allows(
73
            "{$this->vault->getConfig()->guardNamespace()}.{$this->getTarget()}"
74
        );
75
    }
76
}