Completed
Push — master ( 00611e...d96c30 )
by
unknown
01:05
created

ManagesChecks   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 39
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A enableCheck() 0 6 1
A disableCheck() 0 6 1
A requestRun() 0 6 1
A snooze() 0 8 1
A unsnooze() 0 6 1
1
<?php
2
3
namespace OhDear\PhpSdk\Actions;
4
5
use OhDear\PhpSdk\Resources\Check;
6
7
trait ManagesChecks
8
{
9
    public function enableCheck(int $checkId): Check
10
    {
11
        $checkAttributes = $this->post("checks/{$checkId}/enable");
0 ignored issues
show
Bug introduced by
It seems like post() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
12
13
        return new Check($checkAttributes, $this);
14
    }
15
16
    public function disableCheck(int $checkId): Check
17
    {
18
        $checkAttributes = $this->post("checks/{$checkId}/disable");
0 ignored issues
show
Bug introduced by
It seems like post() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
19
20
        return new Check($checkAttributes, $this);
21
    }
22
23
    public function requestRun(int $checkId): Check
24
    {
25
        $checkAttributes = $this->post("checks/{$checkId}/request-run");
0 ignored issues
show
Bug introduced by
It seems like post() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
26
27
        return new Check($checkAttributes, $this);
28
    }
29
30
    public function snooze(int $checkId, int $minutes)
31
    {
32
        $checkAttributes = $this->post("checks/{$checkId}/snooze", [
0 ignored issues
show
Bug introduced by
It seems like post() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
33
            'minutes' => $minutes,
34
        ]);
35
36
        return new Check($checkAttributes, $this);
37
    }
38
39
    public function unsnooze(int $checkId): Check
40
    {
41
        $checkAttributes = $this->post("checks/{$checkId}/unsnooze");
0 ignored issues
show
Bug introduced by
It seems like post() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
42
43
        return new Check($checkAttributes, $this);
44
    }
45
}
46