Passed
Push — master ( 6d9d43...921f98 )
by Alain
02:46
created

EngineFinder::initializeEngines()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
crap 2
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 EngineFinder.
18
 *
19
 * @since   0.1.0
20
 *
21
 * @package BrightNucleus\View\Engine
22
 * @author  Alain Schlesser <[email protected]>
23
 */
24
class EngineFinder 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 EngineInterface Result of the search.
35
     */
36 18
    public function find(array $criteria)
37
    {
38 18
        $this->initializeFindables();
39
40 18
        foreach ($criteria as $entry) {
41 18
            foreach ($this->findables as $engine) {
42 18
                if ($engine->canHandle($entry)) {
43 18
                    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 8
    protected function getFindablesConfigKey()
59
    {
60 8
        return 'Engines';
61
    }
62
}
63