Code Duplication    Length = 20-21 lines in 2 locations

src/Models/Posts.php 1 location

@@ 11-31 (lines=21) @@
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
class Posts extends Store
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
}

src/Models/Threads.php 1 location

@@ 12-31 (lines=20) @@
9
 * @method bool|Thread __get($name) magic method. Returns a thread if the id is set
10
 * @method bool|Thread offsetGet($offset) Returns a thread if the id is set
11
 */
12
class Threads extends Store
13
{
14
    /**
15
     * Threads constructor.
16
     *
17
     * @param $threadsData
18
     */
19
    public function __construct($threadsData)
20
    {
21
        foreach ($threadsData as $thread) {
22
            $this->offsetSet($thread['thread_id'], new Thread($thread));
23
        }
24
    }
25
26
    public function offsetSet($offset, $value)
27
    {
28
        if ($value instanceof Thread)
29
            parent::offsetSet($offset, $value);
30
    }
31
}