Completed
Push — master ( d9631f...300bed )
by Ryan
02:22
created

Resource   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A timestamp() 0 11 4
1
<?php
2
3
namespace SevenShores\Hubspot\Resources;
4
5
abstract class Resource
6
{
7
    /**
8
     * @var \SevenShores\Hubspot\Http\Client
9
     */
10
    protected $client;
11
12
    /**
13
     * Makin' a good ole resource
14
     *
15
     * @param \SevenShores\Hubspot\Http\Client $client
16
     */
17
    function __construct($client)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
18
    {
19
        $this->client = $client;
20
    }
21
22
    /**
23
     * Convert a timestamp or DateTime to a millisecond timestamp.
24
     *
25
     * @param \DateTime|int|null $timestamp
26
     * @return int|null
27
     */
28
    protected function timestamp($timestamp)
29
    {
30
        switch (true) {
31
            case $timestamp instanceof \DateTime:
32
                return $timestamp->getTimestamp() * 1000;
33
            case is_numeric($timestamp) && strlen((string)$timestamp) == 10:
34
                return $timestamp * 1000;
35
            default:
36
                return $timestamp;
37
        }
38
    }
39
}