Test Setup Failed
Push — master ( dcfdf2...6863da )
by guillaume
16:18 queued 10:15
created

FsFileStorage   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 19
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A uriToTmpPicture() 0 7 1
A content() 0 2 1
A setContent() 0 2 1
1
<?php
2
3
4
namespace App\Src\UseCases\Infra\Gateway\Real;
5
6
7
use App\Src\UseCases\Domain\Picture;
8
use App\Src\UseCases\Infra\Gateway\FileStorage;
9
10
class FsFileStorage implements FileStorage
11
{
12
    public function setContent(string $path, array $content)
13
    {
14
        // TODO: Implement setContent() method.
15
    }
16
17
    public function content(string $path): array
18
    {
19
        // TODO: Implement content() method.
20
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return array. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
21
22
    public function uriToTmpPicture(string $uri): Picture
23
    {
24
        $content = file_get_contents($uri);
25
        $ext = 'jpg';
26
        $ph = fopen($path = sys_get_temp_dir().'/'.uniqid(), 'w+');
27
        fwrite($ph, $content);
0 ignored issues
show
Bug introduced by
It seems like $ph can also be of type false; however, parameter $handle of fwrite() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

27
        fwrite(/** @scrutinizer ignore-type */ $ph, $content);
Loading history...
28
        return new Picture($path, $ext);
29
    }
30
31
}
32