FileFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 9
c 2
b 0
f 0
dl 0
loc 20
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A entity() 0 13 2
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
class FileFactory extends AbstractFactory
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