Completed
Push — PSR-11-2 ( a5ad88...7f5041 )
by Nikolaos
03:59
created

LazyInclude   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 29
c 0
b 0
f 0
ccs 5
cts 8
cp 0.625
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of the Phalcon Framework.
5
 *
6
 * (c) Phalcon Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 *
11
 * Implementation of this file has been influenced by AuraPHP
12
 *
13
 * @link    https://github.com/auraphp/Aura.Di
14
 * @license https://github.com/auraphp/Aura.Di/blob/4.x/LICENSE
15
 */
16
17
declare(strict_types=1);
18
19
namespace Phalcon\Container\Injection;
20
21
/**
22
 * Returns the value of `include` when invoked (thereby including the file).
23
 *
24
 * @property string|LazyInterface $file
25
 */
26
class LazyInclude implements LazyInterface
27
{
28
    /**
29
     * The file to include.
30
     *
31
     * @var string|LazyInterface
32
     */
33
    protected $file;
34
35
    /**
36
     * Constructor.
37
     *
38
     * @param string|LazyInterface $file The file to include.
39
     */
40 1
    public function __construct(string $file)
41
    {
42 1
        $this->file = $file;
43 1
    }
44
45
    /**
46
     * Invokes the closure to include the file.
47
     *
48
     * @return mixed The return from the included file, if any.
49
     */
50 1
    public function __invoke()
51
    {
52 1
        return include $this->file;
53
    }
54
}
55