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

AbstractEngine   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 24
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A hasExtension() 0 10 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\Findable;
15
16
/**
17
 * Abstract class AbstractEngine.
18
 *
19
 * @since   0.1.0
20
 *
21
 * @package BrightNucleus\View\Engine
22
 * @author  Alain Schlesser <[email protected]>
23
 */
24
abstract class AbstractEngine implements EngineInterface, Findable
25
{
26
27
    /**
28
     * Check whether a given URI has a specific extension.
29
     *
30
     * @since 0.1.0
31
     *
32
     * @param string $uri       URI to check the extension of.
33
     * @param string $extension Extension to check for.
34
     *
35
     * @return bool
36
     */
37 18
    protected function hasExtension($uri, $extension)
38
    {
39 18
        $uriLength       = mb_strlen($uri);
40 18
        $extensionLength = mb_strlen($extension);
41 18
        if ($extensionLength > $uriLength) {
42 1
            return false;
43
        }
44
45 17
        return substr_compare($uri, $extension, $uriLength - $extensionLength, $extensionLength) === 0;
46
    }
47
}
48