FileInfo::fileSize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Media\Domain\Model;
6
7
final class FileInfo
8
{
9
    private $mimeType;
10
    private $fileSize;
11
12
    public static function fromArray($data): self
13
    {
14
        return new self($data['mime_type'], $data['file_size']);
15
    }
16
17
    public function __construct(string $mimeType, int $fileSize)
18
    {
19
        $this->mimeType = $mimeType;
20
        $this->fileSize = $fileSize;
21
    }
22
23
    public function mimeType(): string
24
    {
25
        return $this->mimeType;
26
    }
27
28
    public function fileSize(): int
29
    {
30
        return $this->fileSize;
31
    }
32
33
    public function image(): bool
34
    {
35
        return 0 === strpos($this->mimeType, 'image/');
36
    }
37
38
    public function sameAs(self $info): bool
39
    {
40
        return $this->mimeType === $info->mimeType && $this->fileSize === $info->fileSize;
41
    }
42
}
43