GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AbstractEngine::parsePartials()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 3
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Parser\Template\Abstracts;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Spl\Traits\Collectors\FileExtensionCollectorTrait;
19
use O2System\Spl\Traits\Collectors\FilePathCollectorTrait;
20
21
/**
22
 * Class AbstractEngine
23
 *
24
 * @package O2System\Parser\Template\Abstracts
25
 */
26
abstract class AbstractEngine
27
{
28
    use FileExtensionCollectorTrait;
29
    use FilePathCollectorTrait;
30
31
    // ------------------------------------------------------------------------
32
33
    /**
34
     * AbstractEngine::parsePartials
35
     *
36
     * @param string  $filename
37
     * @param array   $vars
38
     * @param string  $optionalFilename
39
     *
40
     * @return string|null
41
     */
42
    public function parsePartials($filename, $vars = null, $optionalFilename = null)
43
    {
44
        if (empty($vars)) {
45
            if (isset($optionalFilename)) {
46
                return $this->parseFile($optionalFilename);
47
            }
48
        } else {
49
            return $this->parseFile($filename, $vars);
50
        }
51
52
        return null;
53
    }
54
55
    // ------------------------------------------------------------------------
56
57
    /**
58
     * AbstractEngine::parseFile
59
     *
60
     * @param string $filePath
61
     * @param array  $vars
62
     *
63
     * @return string
64
     */
65
    public function parseFile($filePath, array $vars = [])
66
    {
67
        if (class_exists('O2System\Framework', false)) {
68
            return view()->load($filePath, $vars, true);
0 ignored issues
show
Bug introduced by
The function view was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

68
            return /** @scrutinizer ignore-call */ view()->load($filePath, $vars, true);
Loading history...
69
        } else {
70
            $fileExtension = '.' . pathinfo($filePath, PATHINFO_EXTENSION);
71
72
            if (in_array($fileExtension, $this->fileExtensions) AND is_file($filePath)) {
73
                return $this->parseString(file_get_contents($filePath), $vars);
0 ignored issues
show
Bug introduced by
The method parseString() does not exist on O2System\Parser\Template\Abstracts\AbstractEngine. Since it exists in all sub-types, consider adding an abstract or default implementation to O2System\Parser\Template\Abstracts\AbstractEngine. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

73
                return $this->/** @scrutinizer ignore-call */ parseString(file_get_contents($filePath), $vars);
Loading history...
74
            }
75
76
            // Try to find from filePaths
77
            if (count($this->filePaths)) {
78
                foreach ($this->filePaths as $fileDirectory) {
79
                    $checkFilePath = $fileDirectory . $filePath;
80
81
                    if (in_array($fileExtension, $this->fileExtensions) AND is_file($checkFilePath)) {
82
                        return $this->parseString(file_get_contents($checkFilePath), $vars);
83
                        break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
84
                    }
85
                }
86
            }
87
        }
88
89
        return null;
90
    }
91
}