Completed
Push — dev ( f633ec...231740 )
by Gaige
01:07
created

ManifestReader::getManifest()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace ExoUNX\Vasri;
5
6
7
use Illuminate\Support\Facades\File;
8
use Exception;
9
10
/**
11
 * Class ManifestReader
12
 *
13
 * @package ExoUNX\Vasri
14
 * @author  Gaige Lama <[email protected]>
15
 * @license MIT License
16
 * @link    https://github.com/ExoUNX/Vasri
17
 */
18
class ManifestReader
19
{
20
21
    /**
22
     * @param  string  $file
23
     *
24
     * @return array
25
     */
26
    private function jsonFileToArray(string $file): array
27
    {
28
        return json_decode(file_get_contents($file), true);
29
    }
30
31
    public function getManifest(array $file): array
32
    {
33
        if (File::exists($file)) {
0 ignored issues
show
Documentation introduced by
$file is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
34
            return $this->jsonFileToArray($file);
0 ignored issues
show
Documentation introduced by
$file is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
35
        } else {
36
            throw new Exception('Incorrect file path or file does not exist for '.$file);
37
        }
38
    }
39
40
}
41