Passed
Push — master ( 87ba60...d80a49 )
by Alain
02:43
created

BaseEngineFinder   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 39
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A find() 0 14 4
A getFindablesConfigKey() 0 4 1
1
<?php
2
/**
3
 * Bright Nucleus View Component.
4
 *
5
 * @package   BrightNucleus\View
6
 * @author    Alain Schlesser <[email protected]>
7
 * @license   MIT
8
 * @link      http://www.brightnucleus.com/
9
 * @copyright 2016 Alain Schlesser, Bright Nucleus
10
 */
11
12
namespace BrightNucleus\View\Engine;
13
14
use BrightNucleus\View\Support\AbstractFinder;
15
16
/**
17
 * Class BaseEngineFinder.
18
 *
19
 * @since   0.1.0
20
 *
21
 * @package BrightNucleus\View\Engine
22
 * @author  Alain Schlesser <[email protected]>
23
 */
24
class BaseEngineFinder extends AbstractFinder
25
{
26
27
    /**
28
     * Find a result based on a specific criteria.
29
     *
30
     * @since 0.1.0
31
     *
32
     * @param array $criteria Criteria to search for.
33
     *
34
     * @return Engine Result of the search.
35
     */
36 30
    public function find(array $criteria)
37
    {
38 30
        $this->initializeFindables();
39
40 30
        foreach ($criteria as $entry) {
41 30
            foreach ($this->findables as $engine) {
42 30
                if ($engine->canHandle($entry)) {
43 30
                    return $engine;
44
                }
45
            }
46
        }
47
48 1
        return $this->getNullObject();
49
    }
50
51
    /**
52
     * Get the config key for the Findables definitions.
53
     *
54
     * @since 0.1.0
55
     *
56
     * @return string Config key use to define the Findables.
57
     */
58 16
    protected function getFindablesConfigKey()
59
    {
60 16
        return 'Engines';
61
    }
62
}
63