GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 18e39d...348781 )
by Toby
36:48 queued 23:00
created

Formatter   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 25
c 1
b 0
f 0
dl 0
loc 73
ccs 14
cts 14
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A config() 0 6 2
A canHandle() 0 6 2
A format() 0 5 2
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\ControlDB\Export\Formatter;
4
5
use BristolSU\ControlDB\Contracts\Models\Group;
6
use BristolSU\ControlDB\Contracts\Models\Position;
7
use BristolSU\ControlDB\Contracts\Models\Role;
8
use BristolSU\ControlDB\Contracts\Models\Tags\GroupTag;
9
use BristolSU\ControlDB\Contracts\Models\Tags\GroupTagCategory;
10
use BristolSU\ControlDB\Contracts\Models\Tags\PositionTag;
11
use BristolSU\ControlDB\Contracts\Models\Tags\PositionTagCategory;
12
use BristolSU\ControlDB\Contracts\Models\Tags\RoleTag;
13
use BristolSU\ControlDB\Contracts\Models\Tags\RoleTagCategory;
14
use BristolSU\ControlDB\Contracts\Models\Tags\UserTag;
15
use BristolSU\ControlDB\Contracts\Models\Tags\UserTagCategory;
16
use BristolSU\ControlDB\Contracts\Models\User;
17
use BristolSU\ControlDB\Export\FormattedItem;
18
19
abstract class Formatter
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Formatter
Loading history...
20
{
21
22
    public const USERS = User::class;
23
    
24
    public const GROUPS = Group::class;
25
    
26
    public const ROLES = Role::class;
27
    
28
    public const POSITIONS = Position::class;
29
    
30
    public const USERTAGS = UserTag::class;
31
32
    public const GROUPTAGS = GroupTag::class;
33
34
    public const ROLETAGS = RoleTag::class;
35
36
    public const POSITIONTAGS = PositionTag::class;
37
38
    public const USERTAGCATEGORIES = UserTagCategory::class;
39
40
    public const GROUPTAGCATEGORIES = GroupTagCategory::class;
41
42
    public const ROLETAGCATEGORIES = RoleTagCategory::class;
43
44
    public const POSITIONTAGCATEGORIES = PositionTagCategory::class;
45
    
46
    public const ALL = 'all';
47
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
48
     * @var array
49
     */
50
    protected $config;
51
52 20
    public function __construct(array $config)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
53
    {
54 20
        $this->config = $config;
55 20
    }
56
    
57
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
58
     * @param string $key
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
59
     * @param null $default
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $default is correct as it would always require null to be passed?
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
60
     *
61
     * @return mixed|null
62
     */
63 8
    protected function config(string $key, $default = null)
64
    {
65 8
        if(array_key_exists($key, $this->config)) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
66 7
            return $this->config[$key];
67
        }
68 1
        return $default;
69
    }
70
    
71
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
72
     * @param array|FormattedItem[] $items Items ready to format
0 ignored issues
show
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
73
     * @return array
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
74
     */
75 11
    public function format($items)
76
    {
77
        return array_map(function($item) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
78 11
            return $this->canHandle($item) ? $this->formatItem($item) : $item;
79 11
        }, $items);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
80
    }
81
    
82
    abstract public function formatItem(FormattedItem $formattedItem): FormattedItem;
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function formatItem()
Loading history...
83
84
    abstract public function handles(): string;
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function handles()
Loading history...
85
    
86 11
    protected function canHandle(FormattedItem $item): bool
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function canHandle()
Loading history...
87
    {
88 11
        if($this->handles() === self::ALL) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
89 3
            return true;
90
        }
91 8
        return $item->isType($this->handles());
92
    }
93
94
}