Mention   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 31
loc 31
ccs 8
cts 8
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() 4 4 1
A toArray() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Baguette\Mastodon\Entity;
4
5
/**
6
 * Mention
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#mention
12
 * @property-read string $url      URL of user's profile (can be remote)
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 int    $id       Account ID
16
 */
17 View Code Duplication
class Mention extends Entity
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
{
19
    use \Teto\Object\TypedProperty;
20
21
    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...
22
        'url'      => 'string',
23
        'username' => 'string',
24
        'acct'     => 'string',
25
        'id'       => 'int',
26
    ];
27
28 2
    public function __construct(array $properties)
29
    {
30 2
        $this->setProperties($properties);
31 2
    }
32
33
    /**
34
     * Returns mention data as array
35
     *
36
     * @return array
37
     */
38 3
    public function toArray()
39
    {
40
        return [
41 3
            'url'      => $this->url,
42 3
            'username' => $this->username,
43 3
            'acct'     => $this->acct,
44 3
            'id'       => $this->id,
45
        ];
46
    }
47
}
48