Completed
Push — master ( c2f76d...03586b )
by Freek
11:35
created

File::createFromMedia()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Spatie\MediaLibrary;
4
5
class File
6
{
7
    /** @var string */
8
    public $name;
9
10
    /** @var int */
11
    public $size;
12
13
    /** @var string */
14
    public $mimeType;
15
16
    public static function createFromMedia($media)
17
    {
18
        return new static($media->file_name, $media->size, $media->mime_type);
19
    }
20
21
    public function __construct(string $name, int $size, string $mimeType)
22
    {
23
        $this->name = $name;
24
25
        $this->size = $size;
26
27
        $this->mimeType = $mimeType;
28
    }
29
30
    public function __toString()
31
    {
32
        return "name: {$this->name}, size: {$this->size}, mime: {$this->mimeType}";
33
    }
34
35
36
}