Completed
Push — master ( d96c30...0c0813 )
by
unknown
15s queued 11s
created

ManagesMaintenancePeriods::createSiteMaintenance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace OhDear\PhpSdk\Actions;
4
5
use OhDear\PhpSdk\Resources\MaintenancePeriod;
6
7
trait ManagesMaintenancePeriods
8
{
9
    /**
10
     * @param int $siteId
11
     *
12
     * @return array
13
     */
14
    public function maintenancePeriods(int $siteId): array
15
    {
16
        return $this->transformCollection(
0 ignored issues
show
Bug introduced by
It seems like transformCollection() 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...
17
            $this->get("sites/{$siteId}/maintenance-periods")['data'],
0 ignored issues
show
Bug introduced by
It seems like get() 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...
18
            MaintenancePeriod::class
19
        );
20
    }
21
22
    /**
23
     * @param int $siteId
24
     * @param int $stopMaintenanceAfterSeconds Stops after one hour by default
25
     *
26
     * @return MaintenancePeriod
27
     */
28
    public function startSiteMaintenance(int $siteId, int $stopMaintenanceAfterSeconds = 60 * 60): MaintenancePeriod
29
    {
30
        $attributes = $this->post("sites/{$siteId}/start-maintenance", [
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...
31
            'stop_maintenance_after_seconds' => $stopMaintenanceAfterSeconds,
32
        ]);
33
34
        return new MaintenancePeriod($attributes, $this);
35
    }
36
37
    /**
38
     * @param int $siteId
39
     */
40
    public function stopSiteMaintenance(int $siteId)
41
    {
42
        $this->post("sites/{$siteId}/stop-maintenance");
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...
43
    }
44
45
    /**
46
     * @param int $siteId
47
     * @param string $startsAt Y:m:d H:i
48
     * @param string $endsAt Y:m:d H:i
49
     *
50
     * @return MaintenancePeriod
51
     */
52
    public function createSiteMaintenance(int $siteId, string $startsAt, string $endsAt): MaintenancePeriod
53
    {
54
        $payload = [
55
            'site_id' => $siteId,
56
            'starts_at' => $startsAt,
57
            'ends_at' => $endsAt,
58
        ];
59
60
        $attributes = $this->post('maintenance-periods', $payload);
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...
61
62
        return new MaintenancePeriod($attributes, $this);
63
    }
64
65
    /**
66
     * @param int $maintenancePeriodId
67
     */
68
    public function deleteSiteMaintenance(int $maintenancePeriodId)
69
    {
70
        $this->delete("maintenance-periods/{$maintenancePeriodId}");
0 ignored issues
show
Bug introduced by
The method delete() does not exist on OhDear\PhpSdk\Actions\ManagesMaintenancePeriods. Did you maybe mean deleteSiteMaintenance()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
71
    }
72
}
73