Completed
Push — master ( c2be97...312fc5 )
by Stephen
02:08
created

Posts::offsetSet()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 5
loc 5
rs 9.4286
cc 2
eloc 3
nc 2
nop 2
1
<?php
2
namespace StarCitizen\Models;
3
4
/**
5
 * Class Posts
6
 *
7
 * @package StarCitizen\Models;
8
 * * @method bool|Post __get($name) magic method. Returns a thread if the id is set
9
 * @method bool|Post offsetGet($offset) Returns a thread if the id is set
10
 */
11 View Code Duplication
class Posts extends Store
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    /**
14
     * Posts constructor.
15
     *
16
     * @param $postsData
17
     */
18
    public function __construct($postsData)
19
    {
20
21
        foreach ($postsData as $post) {
22
            $this->offsetSet($post['post']['post_id'], new Post($post['post']));
23
        }
24
    }
25
26
    public function offsetSet($offset, $value)
27
    {
28
        if ($value instanceof Post)
29
            parent::offsetSet($offset, $value);
30
    }
31
}