Applications   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 36
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addApplication() 6 6 1
A removeApplication() 4 4 1
A fromArray() 10 10 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
15
/**
16
 * Model Applications.
17
 */
18 View Code Duplication
class Applications extends ArrayCollection implements FromArrayInterface
19
{
20
    /**
21
     * @param Application $application
22
     *
23
     * @return $this
24
     */
25
    public function addApplication(Application $application)
26
    {
27
        $this->add($application);
28
29
        return $this;
30
    }
31
32
    /**
33
     * @param Application $application
34
     */
35
    public function removeApplication(Application $application)
36
    {
37
        $this->removeElement($application);
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public static function fromArray(array $data)
44
    {
45
        $applications = [];
46
47
        foreach ($data as $datum) {
48
            $applications[] = Application::fromArray($datum);
49
        }
50
51
        return new static($applications);
52
    }
53
}
54