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.

PositionTrait   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A tags() 0 3 1
A data() 0 3 1
A removeTag() 0 3 1
A setDataProviderId() 0 3 1
A roles() 0 3 1
A addTag() 0 3 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
4
namespace BristolSU\ControlDB\Traits;
5
6
7
use BristolSU\ControlDB\Contracts\Models\DataPosition as DataPositionModel;
8
use BristolSU\ControlDB\Contracts\Repositories\DataPosition as DataPositionRepository;
9
use BristolSU\ControlDB\Contracts\Repositories\Pivots\Tags\PositionPositionTag;
10
use BristolSU\ControlDB\Contracts\Repositories\Position;
11
use Illuminate\Support\Collection;
12
13
/**
14
 * Implements common methods using repositories required by the position model interface
15
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
16
trait PositionTrait
17
{
18
19
    /**
20
     * Get the data model for this position
21
     * 
22
     * @return DataPositionModel
23
     */
24 11
    public function data(): DataPositionModel
25
    {
26 11
        return app(DataPositionRepository::class)->getById($this->dataProviderId());
0 ignored issues
show
Bug introduced by
It seems like dataProviderId() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        return app(DataPositionRepository::class)->getById($this->/** @scrutinizer ignore-call */ dataProviderId());
Loading history...
27
    }
28
29
    /**
30
     * Set the ID of the data provider
31
     *
32
     * @param int $dataProviderId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
33
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
34 2
    public function setDataProviderId(int $dataProviderId): void
35
    {
36 2
        app(Position::class)->update($this->id(), $dataProviderId);
0 ignored issues
show
Bug introduced by
It seems like id() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        app(Position::class)->update($this->/** @scrutinizer ignore-call */ id(), $dataProviderId);
Loading history...
37 2
    }
38
39
    /**
40
     * Roles with this position
41
     *
42
     * @return Collection
43
     */
44 3
    public function roles(): Collection
45
    {
46 3
        return app(\BristolSU\ControlDB\Contracts\Repositories\Role::class)->allThroughPosition($this);
0 ignored issues
show
Bug introduced by
$this of type BristolSU\ControlDB\Traits\PositionTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Position expected by parameter $position of BristolSU\ControlDB\Cont...e::allThroughPosition(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

46
        return app(\BristolSU\ControlDB\Contracts\Repositories\Role::class)->allThroughPosition(/** @scrutinizer ignore-type */ $this);
Loading history...
47
    }
48
49
    /**
50
     * Tags the position is tagged with
51
     *
52
     * @return Collection
53
     */
54 2
    public function tags(): Collection
55
    {
56 2
        return app(PositionPositionTag::class)->getTagsThroughPosition($this);
0 ignored issues
show
Bug introduced by
$this of type BristolSU\ControlDB\Traits\PositionTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Position expected by parameter $position of BristolSU\ControlDB\Cont...etTagsThroughPosition(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

56
        return app(PositionPositionTag::class)->getTagsThroughPosition(/** @scrutinizer ignore-type */ $this);
Loading history...
57
    }
58
59
    /**
60
     * Add a tag to the position
61
     * 
62
     * @param \BristolSU\ControlDB\Contracts\Models\Tags\PositionTag $positionTag
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
63
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
64 6
    public function addTag(\BristolSU\ControlDB\Contracts\Models\Tags\PositionTag $positionTag): void
65
    {
66 6
        app(PositionPositionTag::class)->addTagToPosition($positionTag, $this);
0 ignored issues
show
Bug introduced by
$this of type BristolSU\ControlDB\Traits\PositionTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Position expected by parameter $position of BristolSU\ControlDB\Cont...Tag::addTagToPosition(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

66
        app(PositionPositionTag::class)->addTagToPosition($positionTag, /** @scrutinizer ignore-type */ $this);
Loading history...
67 6
    }
68
69
    /**
70
     * Remove a tag from the position
71
     * 
72
     * @param \BristolSU\ControlDB\Contracts\Models\Tags\PositionTag $positionTag
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
73
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
74 2
    public function removeTag(\BristolSU\ControlDB\Contracts\Models\Tags\PositionTag $positionTag): void
75
    {
76 2
        app(PositionPositionTag::class)->removeTagFromPosition($positionTag, $this);
0 ignored issues
show
Bug introduced by
$this of type BristolSU\ControlDB\Traits\PositionTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\Position expected by parameter $position of BristolSU\ControlDB\Cont...removeTagFromPosition(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

76
        app(PositionPositionTag::class)->removeTagFromPosition($positionTag, /** @scrutinizer ignore-type */ $this);
Loading history...
77 2
    }
78
    
79
}