Passed
Push — master ( 240c83...03f39b )
by Mathias
06:41
created

UploadedFileInfo   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
eloc 15
dl 0
loc 53
rs 10
c 1
b 0
f 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getImageFormat() 0 7 2
A fromArray() 0 3 1
A getName() 0 3 1
A getContentType() 0 3 1
A getTmpFile() 0 3 1
A __construct() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Core\Service;
6
7
8
class UploadedFileInfo
9
{
10
    private string $contentType;
11
    private string $name;
12
    private string $tmpFile;
13
14
    public function __construct(
15
        string $name,
16
        string $contentType,
17
        string $tmpFile
18
    )
19
    {
20
        $this->contentType = $contentType;
21
        $this->name = $name;
22
        $this->tmpFile = $tmpFile;
23
    }
24
25
    public static function fromArray(array $data)
26
    {
27
        return new self($data['name'], $data['type'], $data['tmp_name']);
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function getContentType(): string
34
    {
35
        return $this->contentType;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getName(): string
42
    {
43
        return $this->name;
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getTmpFile(): string
50
    {
51
        return $this->tmpFile;
52
    }
53
54
    public function getImageFormat(): ?string
55
    {
56
        $format = null;
57
        if(!is_null($this->contentType)){
0 ignored issues
show
introduced by
The condition is_null($this->contentType) is always false.
Loading history...
58
            $format = str_replace('image/', '', $this->contentType);
59
        }
60
        return $format;
61
    }
62
}