Passed
Push — master ( af7542...44a008 )
by Petr
02:16
created

MenuFactory::getProcessor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
namespace kalanis\kw_menu;
4
5
6
use kalanis\kw_files\FilesException;
7
use kalanis\kw_menu\Interfaces\IMNTranslations;
8
use kalanis\kw_menu\Traits\TLang;
9
use kalanis\kw_paths\PathsException;
10
11
12
/**
13
 * Class MenuFactory
14
 * @package kalanis\kw_menu
15
 * Create menu processing
16
 */
17
class MenuFactory
18
{
19
    use TLang;
20
21 2
    public function __construct(?IMNTranslations $lang = null)
22
    {
23 2
        $this->setMnLang($lang);
24 2
    }
25
26
    /**
27
     * @param mixed $params
28
     * @param mixed $parser
29
     * @throws FilesException
30
     * @throws MenuException
31
     * @throws PathsException
32
     * @return MoreEntries
33
     */
34 2
    public function getMenu($params, $parser = null): MoreEntries
35
    {
36 2
        return new MoreEntries(
37 2
            $this->getProcessor($params, $parser),
38 2
            (new EntriesSource\Factory($this->getMnLang()))->getSource($params)
39
        );
40
    }
41
42
    /**
43
     * @param mixed $params
44
     * @param mixed $parser
45
     * @throws FilesException
46
     * @throws MenuException
47
     * @throws PathsException
48
     * @return MetaProcessor
49
     */
50 2
    public function getProcessor($params, $parser = null): MetaProcessor
51
    {
52 2
        return new MetaProcessor(
53 2
            (new MetaSource\Factory($this->getMnLang()))->getSource($params, $parser),
54 2
            $this->getMnLang()
55
        );
56
    }
57
}
58