Completed
Push — master ( cc3f25...fdac0f )
by Nicolas
02:44
created

Video::videoable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Nwidart\LaravelVideoable\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Nwidart\LaravelVideoable\Exceptions\VideoPresenterNotFound;
7
8
class Video extends Model
9
{
10
    protected $table = 'laravel_videoables';
11
    protected $fillable = ['source', 'code', 'title', 'width', 'height', 'videoable_id', 'videoable_type'];
12
13
    public function videoable()
14
    {
15
        return $this->morphTo();
16
    }
17
18 4
    public function getEmbed()
19
    {
20 4
        $sourceClass = config("laravel-videoable.sources.{$this->source}");
21
22 4
        if (class_exists($sourceClass) === false) {
23 1
            throw new VideoPresenterNotFound($sourceClass);
24
        }
25
26 3
        return (new $sourceClass(get_object_vars($this)))->getEmbedCode();
27
    }
28
}
29