Context   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 7
cts 7
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 7 1
A toArray() 0 7 1
1
<?php
2
3
namespace Baguette\Mastodon\Entity;
4
5
/**
6
 * Context
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#context
12
 * @property-read Status[] $ancestors   ancestors of the status in the conversation
13
 * @property-read Status[] $descendants descendants of the status in the conversation
14
 */
15
class Context extends Entity
16
{
17
    use \Teto\Object\TypedProperty;
18
19
    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...
20
        'ancestors'   => 'Baguette\Mastodon\Entity\Status[]',
21
        'descendants' => 'Baguette\Mastodon\Entity\Status[]',
22
    ];
23
24 2
    public function __construct(array $properties)
25
    {
26 2
        $this->setProperties(mapValues($properties, [
27 2
            'ancestors'   => [Status::class],
28
            'descendants' => [Status::class],
29
        ]));
30 2
    }
31
32
    /**
33
     * Returns context data as array
34
     *
35
     * @return array
36
     */
37 2
    public function toArray()
38
    {
39
        return [
40 2
            'ancestors'   => toArrayValue($this->ancestors),
41 2
            'descendants' => toArrayValue($this->descendants),
42
        ];
43
    }
44
}
45