GramFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 11
dl 0
loc 29
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createGramsFromXML() 0 22 3
1
<?php
2
3
namespace Cowglow\InstagramGallery\Application;
4
5
use Cowglow\InstagramGallery\Domain\Gram;
6
7
/**
8
 * Class GramFactory
9
 * @package Cowglow\InstagramGallery\Application
10
 */
11
class GramFactory
12
{
13
    /**
14
     * @param \SimpleXMLElement $xml
15
     *
16
     * @return array
17
     */
18
    public static function createGramsFromXML(\SimpleXMLElement $xml): array
19
    {
20
        $grams = [];
21
22
        foreach ($xml as $node) {
23
            $gram  = new Gram();
24
            $key   = '';
25
            $value = '';
26
27
            /**
28
             * TODO: Build loop
29
             */
30
31
            $setter = 'set'.ucfirst($key);
32
            if (is_callable([$grams, $setter])) {
33
                $gram->$setter($key, $value);
34
            }
35
36
            array_push($grams, $gram);
37
        }
38
39
        return $grams;
40
    }
41
}
42