Completed
Pull Request — master (#3)
by Aymen
02:02
created

Applications::fromArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
/**
3
 * This file is part of the fnayou/instapush-php project.
4
 *
5
 * Copyright (c) 2017. Aymen FNAYOU <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Fnayou\InstapushPHP\Model;
12
13
use Doctrine\Common\Collections\ArrayCollection;
14
use Fnayou\InstapushPHP\Model\FromArrayInterface;
15
16
/**
17
 * Model Applications.
18
 */
19 View Code Duplication
class Applications extends ArrayCollection implements FromArrayInterface
20
{
21
    /**
22
     * @param Application $application
23
     *
24
     * @return $this
25
     */
26
    public function addApplication(Application $application)
27
    {
28
        $this->add($application);
29
30
        return $this;
31
    }
32
33
    /**
34
     * @param Application $application
35
     */
36
    public function removeApplication(Application $application)
37
    {
38
        $this->removeElement($application);
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public static function fromArray(array $data)
45
    {
46
        $applications = [];
47
48
        foreach ($data as $datum) {
49
            $applications[] = Application::fromArray($datum);
50
        }
51
52
        return new static($applications);
53
    }
54
}
55