Completed
Push — 3.x ( e32815...7c4255 )
by Ryota
09:26 queued 05:13
created

FileFactory::entity()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Polidog\Chatwork\Entity\Factory;
6
7
use Cake\Utility\Inflector;
8
use Polidog\Chatwork\Entity\File;
9
10 View Code Duplication
class FileFactory extends AbstractFactory
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    /**
13
     * @param array $data
14
     *
15
     * @return File
16
     */
17
    public function entity(array $data = [])
18
    {
19
        $userFactory = new UserFactory();
20
        $file = new File();
21
        $file->account = $userFactory->entity($data['account']);
22
        unset($data['account']);
23
24
        foreach ($data as $key => $value) {
25
            $property = Inflector::variable($key);
26
            $file->$property = $value;
27
        }
28
29
        return $file;
30
    }
31
}
32