Passed
Push — master ( 0d1e15...689c60 )
by Julito
08:05
created

AbstractTool::getNameToShow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Tool;
8
9
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
10
use Symfony\Component\Serializer\Annotation\Groups;
11
12
abstract class AbstractTool implements ToolInterface
13
{
14
    /**
15
     * @Groups({"ctool:read"})
16
     */
17
    protected string $name;
18
19
    /**
20
     * @Groups({"ctool:read"})
21
     */
22
    protected string $nameToShow;
23
24
    /**
25
     * @Groups({"ctool:read"})
26
     */
27
    protected string $icon;
28
    protected string $category;
29
    protected string $link;
30
    protected string $image;
31
    protected string $admin;
32
    protected ?SchemaInterface $settings = null;
33
    protected ?array $resourceTypes;
34
35
    /**
36
     * @var string
37
     *
38
     *  00 disabled tool
39
     *  01 course tool
40
     *  10 global tool
41
     *  11 global or course or both
42
     */
43
    protected string $scope;
44
45
    public function __construct(
46
        string $name,
47
        string $category,
48
        string $link,
49
        ?SchemaInterface $settings = null,
50
        ?array $resourceTypes = []
51
    ) {
52
        $this->name = $name;
53
        $this->nameToShow = $name;
54
        $this->category = $category;
55
        $this->link = $link;
56
        $this->image = $name.'.png';
57
        $this->settings = $settings;
58
        $this->resourceTypes = $resourceTypes;
59
        $this->icon = 'mdi-crop-square';
60
    }
61
62
    public function isCourseTool(): bool
63
    {
64
        return false;
65
    }
66
67
    public function isGlobal(): bool
68
    {
69
        return true;
70
    }
71
72
    public function getName(): string
73
    {
74
        return $this->name;
75
    }
76
77
    public function getLink(): string
78
    {
79
        return $this->link ?: '';
80
    }
81
82
    public function getCategory(): string
83
    {
84
        return $this->category;
85
    }
86
87
    public function getTarget(): string
88
    {
89
        return '_self';
90
    }
91
92
    public function getImage(): string
93
    {
94
        return $this->image;
95
    }
96
97
    public function getResourceTypes(): ?array
98
    {
99
        return $this->resourceTypes;
100
    }
101
102
    public function setResourceTypes(?array $resourceTypes): self
103
    {
104
        $this->resourceTypes = $resourceTypes;
105
106
        return $this;
107
    }
108
109
    public function getIcon(): string
110
    {
111
        return $this->icon;
112
    }
113
114
    public function setIcon(string $icon): self
115
    {
116
        $this->icon = $icon;
117
118
        return $this;
119
    }
120
121
    public function getNameToShow(): string
122
    {
123
        return ucfirst(str_replace('_', ' ', $this->nameToShow));
124
    }
125
126
    public function setNameToShow(string $nameToShow): AbstractTool
127
    {
128
        $this->nameToShow = $nameToShow;
129
130
        return $this;
131
    }
132
}
133