Completed
Push — master ( 2b8a9b...6ad9e4 )
by Asmir
10:57 queued 10:57
created

BaseTwitalLoader::getSourceContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 0
cp 0
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
namespace Goetas\Twital;
3
4
use Twig\Loader\ExistsLoaderInterface;
5
use Twig\Loader\LoaderInterface;
6
use Twig\Loader\SourceContextLoaderInterface;
7
8
if (interface_exists(\Twig_ExistsLoaderInterface::class)) { // Twig 1
9
    abstract class BaseTwitalLoader extends TwitalLoaderTwigLt3 implements \Twig_LoaderInterface, \Twig_ExistsLoaderInterface, \Twig_SourceContextLoaderInterface
10
    {
11
        /**
12
         * {@inheritdoc}
13
         */
14
        public function getSource($name)
15
        {
16
            return $this->getSourceContext($name)->getCode();
17
        }
18
    }
19
} elseif (interface_exists(ExistsLoaderInterface::class)) { // Twig 2
20
    abstract class BaseTwitalLoader extends TwitalLoaderTwigLt3 implements LoaderInterface, ExistsLoaderInterface, SourceContextLoaderInterface
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type Goetas\Twital\BaseTwitalLoader has been defined more than once; this definition is ignored, only the first definition in this file (L9-18) is considered.

This check looks for classes that have been defined more than once in the same file.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
21
    {
22
    }
23
} else { // Twig 3
24
    abstract class BaseTwitalLoader extends TwitalLoaderTwigGte3
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type Goetas\Twital\BaseTwitalLoader has been defined more than once; this definition is ignored, only the first definition in this file (L9-18) is considered.

This check looks for classes that have been defined more than once in the same file.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
25
    {
26
    }
27
}
28
29
/**
30
 * This is a Twital Loader.
31
 * Compiles a Twital template into a Twig template.
32
 *
33
 * @author Asmir Mustafic <[email protected]>
34
 */
35
class TwitalLoader extends BaseTwitalLoader
36
{
37
}
38