Test Setup Failed
Push — feature/super-model ( 86f2ea...9eaa75 )
by axel
09:29 queued 07:56
created

UserCoverModel::getAllInfo()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 3
nop 0
dl 0
loc 15
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace MalScraper\Model\User;
4
5
use MalScraper\Model\User\UserListModel as UserList;
6
7
/**
8
 * UserCoverModel class.
9
 */
10
class UserCoverModel
11
{
12
    /**
13
     * Username.
14
     *
15
     * @var string
16
     */
17
    private $_user;
18
19
    /**
20
     * Either anime or manga.
21
     *
22
     * @var string
23
     */
24
    private $_type;
25
26
    /**
27
     * CSS style.
28
     *
29
     * @var string
30
     */
31
    private $_style;
32
33
    /**
34
     * Default constructor.
35
     *
36
     * @param string $user
37
     * @param string $type
38
     * @param string $style
39
     * @param string $parserArea
40
     *
41
     * @return void
42
     */
43
    public function __construct($user, $type, $style)
44
    {
45
        $this->_user = $user;
46
        $this->_type = $type;
47
        if ($style) {
48
            $this->_style = $style;
49
        } else {
50
            $this->_style = "tr:hover .animetitle[href*='/{id}/']:before{background-image:url({url})}";
51
        }
52
    }
53
54
    /**
55
     * Get user cover.
56
     *
57
     * @return string
58
     */
59
    public function getAllInfo()
60
    {
61
        $list = (new UserList($this->_user, $this->_type, 7))->getAllInfo();
62
63
        $cover = '';
64
        foreach ($list as $c) {
0 ignored issues
show
Bug introduced by
The expression $list of type string is not traversable.
Loading history...
65
            if ($this->_type == 'anime') {
66
                $temp = str_replace(['{id}', '{url}'], [$c['anime_id'], $c['anime_image_path']], $this->_style);
67
            } else {
68
                $temp = str_replace(['{id}', '{url}'], [$c['manga_id'], $c['manga_image_path']], $this->_style);
69
            }
70
            $cover .= $temp."\n";
71
        }
72
73
        return $cover;
74
    }
75
}
76