Issues (34)

src/Actions/ManagesMaintenancePeriods.php (5 issues)

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
It seems like transformCollection() 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

16
        return $this->/** @scrutinizer ignore-call */ transformCollection(
Loading history...
17
            $this->get("sites/{$siteId}/maintenance-periods")['data'],
0 ignored issues
show
It seems like get() 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

17
            $this->/** @scrutinizer ignore-call */ 
18
                   get("sites/{$siteId}/maintenance-periods")['data'],
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
It seems like post() 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

30
        /** @scrutinizer ignore-call */ 
31
        $attributes = $this->post("sites/{$siteId}/start-maintenance", [
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");
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
        $startsAt = $this->convertDateFormat($startsAt, 'Y:m:d H:i');
0 ignored issues
show
It seems like convertDateFormat() 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

54
        /** @scrutinizer ignore-call */ 
55
        $startsAt = $this->convertDateFormat($startsAt, 'Y:m:d H:i');
Loading history...
55
        $endsAt = $this->convertDateFormat($endsAt, 'Y:m:d H:i');
56
57
        $payload = [
58
            'site_id' => $siteId,
59
            'starts_at' => $startsAt,
60
            'ends_at' => $endsAt,
61
        ];
62
63
        $attributes = $this->post('maintenance-periods', $payload);
64
65
        return new MaintenancePeriod($attributes, $this);
66
    }
67
68
    /**
69
     * @param int $maintenancePeriodId
70
     */
71
    public function deleteSiteMaintenance(int $maintenancePeriodId)
72
    {
73
        $this->delete("maintenance-periods/{$maintenancePeriodId}");
0 ignored issues
show
The method delete() does not exist on OhDear\PhpSdk\Actions\ManagesMaintenancePeriods. Did you maybe mean deleteSiteMaintenance()? ( Ignorable by Annotation )

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

73
        $this->/** @scrutinizer ignore-call */ 
74
               delete("maintenance-periods/{$maintenancePeriodId}");

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
74
    }
75
}
76