AbstractFactory::collection()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 12
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Polidog\Chatwork\Entity\Factory;
6
7
use Polidog\Chatwork\Entity\Collection\EntityCollection;
8
9
abstract class AbstractFactory implements FactoryInterface
10
{
11
    protected $collectionName = EntityCollection::class;
12
13
    /**
14
     * @param array $listUp
15
     *
16
     * @return EntityCollection
17
     */
18
    public function collection($listUp = null)
19
    {
20
        $collection = new $this->collectionName();
21
        if (!is_array($listUp)) {
22
            return $collection;
23
        }
24
25
        foreach ($listUp as $value) {
26
            $collection->add($this->entity($value));
27
        }
28
29
        return $collection;
30
    }
31
}
32