Short   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 8
c 3
b 0
f 0
dl 0
loc 18
ccs 9
cts 9
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setUrlAttribute() 0 6 1
1
<?php
2
3
namespace Helldar\ShortUrl\Models;
4
5
use Helldar\Support\Facades\Helpers\HttpBuilder;
6
use Illuminate\Database\Eloquent\Builder;
7
use Illuminate\Database\Eloquent\Model;
8
9
/**
10
 * @property int id
11
 * @property string|null $key
12
 * @property string $host
13
 * @property string $url
14
 * @property int $visited
15
 * @property \Illuminate\Support\Carbon|null $created_at
16
 * @property \Illuminate\Support\Carbon|null $updated_at
17
 *
18
 * @method static Builder|Short newModelQuery()
19
 * @method static Builder|Short newQuery()
20
 * @method static Builder|Short query()
21
 * @method static Builder|Short whereId($value)
22
 * @method static Builder|Short whereKey($value)
23
 * @method static Builder|Short whereHost($value)
24
 * @method static Builder|Short whereUrl($value)
25
 * @method static Builder|Short whereVisited($value)
26
 * @method static Builder|Short whereCreatedAt($value)
27
 * @method static Builder|Short whereUpdatedAt($value)
28
 */
29
class Short extends Model
30
{
31
    protected $fillable = ['key', 'host', 'url', 'visited'];
32
33 7
    public function __construct(array $attributes = [])
34
    {
35 7
        $this->connection = config('short_url.connection');
36 7
        $this->table      = config('short_url.table', 'shorts');
37
38 7
        parent::__construct($attributes);
39 7
    }
40
41 5
    protected function setUrlAttribute(string $url)
42
    {
43 5
        $builder = HttpBuilder::parse($url);
44
45 5
        $this->attributes['url']  = $builder->compile();
46 5
        $this->attributes['host'] = $builder->getHost();
47 5
    }
48
}
49