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

MenuFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 38
ccs 11
cts 11
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getProcessor() 0 5 1
A getMenu() 0 5 1
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