Completed
Push — master ( fea2cb...118c60 )
by Litera
21s
created

CategoryService   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 57
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A all() 0 4 1
A getStyleFromName() 0 7 1
A getCategoryModel() 0 4 1
A setCategoryModel() 0 6 1
1
<?php
2
3
namespace App\Services;
4
5
use Tracy\Debugger;
6
use Nette\Utils\Strings;
7
use App\Models\CategoryModel;
8
use Nette\Database\Table\ActiveRow;
9
10
class CategoryService
11
{
12
13
	/**
14
	 * @var CategoryModel
15
	 */
16
	private $categoryModel;
17
18
	/**
19
	 * @param CategoryModel $categoryModel
20
	 */
21
	public function __construct(CategoryModel $categoryModel)
22
	{
23
		$this->setCategoryModel($categoryModel);
24
	}
25
26
	/**
27
	 * @return array
28
	 */
29
	public function all(): array
30
	{
31
		return $this->getCategoryModel()->all();
32
	}
33
34
	/**
35
	 * @param  string $name
36
	 * @return string
37
	 */
38
	protected function getStyleFromName($name)
39
	{
40
		$style = Strings::toAscii($name);
41
		$style = str_replace(" ", "_", $style);
42
43
		return $style;
44
	}
45
46
	/**
47
	 * @return CategoryModel
48
	 */
49
	public function getCategoryModel(): CategoryModel
50
	{
51
		return $this->categoryModel;
52
	}
53
54
	/**
55
	 * @param CategoryModel $categoryModel
56
	 *
57
	 * @return self
58
	 */
59
	public function setCategoryModel(CategoryModel $categoryModel): self
60
	{
61
		$this->categoryModel = $categoryModel;
62
63
		return $this;
64
	}
65
66
}
67