Plugin   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 78
ccs 8
cts 12
cp 0.6667
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fill() 0 11 3
A toArray() 0 4 1
A upToDate() 0 8 2
1
<?php
2
3
namespace Darkgoldblade01\Wordpress\Models;
4
5
/**
6
 * Class Model.
7
 */
8
class Plugin
9
{
10
    public $name;
11
    public $slug;
12
    public $version;
13
    public $author;
14
    public $author_profile;
15
    public $contributors;
16
    public $requires;
17
    public $tested;
18
    public $requires_php;
19
    public $rating;
20
    public $ratings;
21
    public $num_ratings;
22
    public $support_threads;
23
    public $support_threads_resolved;
24
    public $active_installs;
25
    public $last_updated;
26
    public $added;
27
    public $homepage;
28
    public $download_link;
29
    public $screenshots;
30
    public $tags;
31
    public $versions;
32
    public $donate_link;
33
    public $banners;
34
35
    /**
36
     * Fill the Model with
37
     * the data from the array.
38
     *
39
     * @param array $data
40
     *
41
     * @return Plugin
42
     */
43 2
    public function fill(array $data): Plugin
44
    {
45 2
        foreach ($data as $key => $value) {
46 2
            if ($key === 'url') {
47
                continue;
48
            }
49 2
            $this->{$key} = $value;
50
        }
51
52 2
        return $this;
53
    }
54
55
    /**
56
     * Convert the Model to an array.
57
     *
58
     * @return array
59
     */
60
    public function toArray(): array
61
    {
62
        return (array) $this;
63
    }
64
65
    /**
66
     * Up to Date.
67
     *
68
     * Checks the version of the current plugin vs. the
69
     * version supplied and returns true or false.
70
     *
71
     * If the plugin is greater than or equal to the current version,
72
     * return true, else return false.
73
     *
74
     * @param $version
75
     * @return bool
76
     */
77 1
    public function upToDate($version): bool
78
    {
79 1
        if (version_compare($this->version, $version, '>=')) {
80 1
            return true;
81
        } else {
82
            return false;
83
        }
84
    }
85
}
86