ManagesPerformance::performanceRecords()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 4
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace OhDear\PhpSdk\Actions;
4
5
use OhDear\PhpSdk\Resources\PerformanceRecord;
6
7
trait ManagesPerformance
8
{
9
    /**
10
     * @param int $siteId
11
     * @param string $start Short (2020-12-01) or long (2020-12-01 15:00:00) date format
12
     * @param string $end Short (2020-12-01) or long (2020-12-01 15:00:00) date format
13
     * @param string $timeframe Should be 1m or 1h
14
     *
15
     * @return array
16
     */
17
    public function performanceRecords(int $siteId, string $start, string $end, string $timeframe = '1m'): array
18
    {
19
        $start = $this->convertDateFormat($start);
0 ignored issues
show
Bug introduced by
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

19
        /** @scrutinizer ignore-call */ 
20
        $start = $this->convertDateFormat($start);
Loading history...
20
        $end = $this->convertDateFormat($end);
21
22
        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? ( Ignorable by Annotation )

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

22
        return $this->/** @scrutinizer ignore-call */ transformCollection(
Loading history...
23
            $this->get("sites/$siteId/performance-records?filter[start]={$start}&filter[end]={$end}&filter[timeframe]={$timeframe}"),
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? ( Ignorable by Annotation )

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

23
            $this->/** @scrutinizer ignore-call */ 
24
                   get("sites/$siteId/performance-records?filter[start]={$start}&filter[end]={$end}&filter[timeframe]={$timeframe}"),
Loading history...
24
            PerformanceRecord::class
25
        );
26
    }
27
}
28