Meta   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 11
c 1
b 0
f 0
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setDate() 0 5 1
A __construct() 0 6 1
1
<?php
2
3
namespace Pixelpeter\Genderize\Models;
4
5
use Carbon\Carbon;
6
7
class Meta extends BaseModel
8
{
9
    protected $code;
10
11
    protected $limit;
12
13
    protected $remaining;
14
15
    protected $reset;
16
17
    /**
18
     * Create new instance of Meta model
19
     */
20
    public function __construct($data)
21
    {
22
        $this->code = (int) $data->code;
23
        $this->limit = (int) $data->headers['x-rate-limit-limit'];
24
        $this->remaining = (int) $data->headers['x-rate-limit-remaining'];
25
        $this->reset = $this->setDate($data);
26
    }
27
28
    /**
29
     * Set remaining seconds till reset as Carbon instance
30
     */
31
    protected function setDate($data)
32
    {
33
        $date = Carbon::now();
34
35
        return $date->addSeconds($data->headers['x-rate-reset']);
36
    }
37
}
38