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

CategoryService::__construct()   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 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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