Account   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 55
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A toArray() 0 20 1
1
<?php
2
3
namespace Baguette\Mastodon\Entity;
4
5
/**
6
 * Account
7
 *
8
 * @author    USAMI Kenta <[email protected]>
9
 * @copyright 2017 Baguette HQ
10
 * @license   https://www.gnu.org/licenses/gpl-3.0.html GPL-3.0
11
 * @see https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#account
12
 * @property-read int    $id           The ID of the account
13
 * @property-read string $username     The username of the account
14
 * @property-read string $acct         Equals username for local users, includes @domain for remote ones
15
 * @property-read string $display_name The account's display name
16
 * @property-read bool   $locked       Boolean for when the account cannot be followed without waiting for approval first
17
 * @property-read \DateTimeImmutable $created_at The time the account was created
18
 * @property-read int    $followers_count The number of followers for the account
19
 * @property-read int    $following_count The number of accounts the given account is following
20
 * @property-read int    $statuses_count  The number of statuses the account has made
21
 * @property-read string $note Biography of user
22
 * @property-read string $url  URL of the user's profile page (can be remote)
23
 * @property-read string $avatar        URL to the avatar image
24
 * @property-read string $avatar_static URL to the avatar static image (gif)
25
 * @property-read string $header        URL to the header image
26
 * @property-read string $header_static URL to the header static image (gif)
27
 */
28
class Account extends Entity
29
{
30
    use \Teto\Object\TypedProperty;
31
32
    private static $property_types = [
0 ignored issues
show
Unused Code introduced by
The property $property_types is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
33
        'id'              => 'int',
34
        'username'        => 'string',
35
        'acct'            => 'string',
36
        'display_name'    => 'string',
37
        'locked'          => 'bool',
38
        'created_at'      => \DateTimeImmutable::class,
39
        'followers_count' => 'int',
40
        'following_count' => 'int',
41
        'statuses_count'  => 'int',
42
        'note'            => 'string',
43
        'url'             => 'string',
44
        'avatar'          => 'string',
45
        'avatar_static'   => 'string',
46
        'header'          => 'string',
47
        'header_static'   => 'string',
48
    ];
49
50 3
    public function __construct(array $properties)
51
    {
52 3
        $this->setProperties(mapValues($properties, [
53 3
            'created_at' => \DateTimeImmutable::class,
54
        ]));
55 3
    }
56
57
    /**
58
     * Returns account data as array
59
     *
60
     * @return array
61
     */
62 4
    public function toArray()
63
    {
64
        return [
65 4
            'id'              => $this->id,
66 4
            'username'        => $this->username,
67 4
            'acct'            => $this->acct,
68 4
            'display_name'    => $this->display_name,
69 4
            'locked'          => $this->locked,
70 4
            'created_at'      => toArrayValue($this->created_at),
71 4
            'followers_count' => $this->followers_count,
72 4
            'following_count' => $this->following_count,
73 4
            'statuses_count'  => $this->statuses_count,
74 4
            'note'            => $this->note,
75 4
            'url'             => $this->url,
76 4
            'avatar'          => $this->avatar,
77 4
            'avatar_static'   => $this->avatar_static,
78 4
            'header'          => $this->header,
79 4
            'header_static'   => $this->header_static,
80
        ];
81
    }
82
}
83