Meta   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
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 30
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
    protected $limit;
11
    protected $remaining;
12
    protected $reset;
13
14
    /**
15
     * Create new instance of Meta model
16
     *
17
     * @param $data
18
     */
19
    public function __construct($data)
20
    {
21
        $this->code = (int)$data->code;
22
        $this->limit = (int)$data->headers['X-Rate-Limit-Limit'];
23
        $this->remaining = (int)$data->headers['X-Rate-Limit-Remaining'];
24
        $this->reset = $this->setDate($data);
25
    }
26
27
    /**
28
     * Set remaining seconds till reset as Carbon instance
29
     *
30
     * @param $data
31
     */
32
    protected function setDate($data)
33
    {
34
        $date = Carbon::now();
35
36
        return $date->addSeconds($data->headers['X-Rate-Reset']);
37
    }
38
}
39