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

File   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createFromMedia() 0 4 1
A __construct() 0 8 1
A __toString() 0 4 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
}