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

LazyInclude::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.0156

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 3
cts 4
cp 0.75
rs 10
cc 1
nc 1
nop 1
crap 1.0156
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