GenericFileFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 52
ccs 15
cts 15
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A make() 0 13 1
1
<?php
2
3
/**
4
 * This file is part of InFw\File package.
5
 */
6
7
namespace InFw\File;
8
9
use InFw\Size\SizeFactoryInterface;
10
11
/**
12
 * Class GenericFileFactory.
13
 */
14
class GenericFileFactory implements FileFactoryInterface
15
{
16
    /**
17
     * Mime type Factory.
18
     *
19
     * @var MimeTypeFactoryInterface
20
     */
21
    protected $mimeType;
22
23
    /**
24
     * Size Factory.
25
     *
26
     * @var SizeFactoryInterface
27
     */
28
    protected $size;
29
30
    /**
31
     * GenericFileFactory constructor.
32
     *
33
     * @param MimeTypeFactoryInterface $mimeTypeFactory
34
     * @param SizeFactoryInterface     $sizeFactory
35
     */
36 3
    public function __construct(
37
        MimeTypeFactoryInterface $mimeTypeFactory,
38
        SizeFactoryInterface $sizeFactory
39
    ) {
40 3
        $this->mimeType = $mimeTypeFactory;
41 3
        $this->size = $sizeFactory;
42 3
    }
43
44
    /**
45
     * Make instances of GenericFile.
46
     *
47
     * @param string $name
48
     * @param string $filePath
49
     *
50
     * @return FileInterface
51
     */
52 3
    public function make($name, $filePath)
53
    {
54 3
        return new GenericFile(
55 2
            $name,
56 3
            $this->mimeType->make(
57 3
                mime_content_type($filePath)
58 2
            ),
59 3
            $this->size->make(
60 3
                filesize($filePath)
61 2
            ),
62 1
            $filePath
63 2
        );
64
    }
65
}
66