H5pLibrary::getCountContentDependencies()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 4
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace Djoudi\LaravelH5p\Eloquents;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Support\Facades\App;
7
8
class H5pLibrary extends Model
9
{
10
    protected $primaryKey = 'id';
11
    protected $fillable = [
12
        'name',
13
        'title',
14
        'major_version',
15
        'minor_version',
16
        'patch_version',
17
        'runnable',
18
        'restricted',
19
        'fullscreen',
20
        'embed_types',
21
        'preloaded_js',
22
        'preloaded_css',
23
        'drop_library_css',
24
        'semantics',
25
        'tutorial_url',
26
        'has_icon',
27
        'created_at',
28
        'updated_at',
29
    ];
30
31
    public function numContent()
32
    {
33
        $h5p = App::make('LaravelH5p');
34
        $interface = $h5p::$interface;
35
36
        return intval($interface->getNumContent($this->id));
37
    }
38
39
    public function getCountContentDependencies()
40
    {
41
        $h5p = App::make('LaravelH5p');
42
        $interface = $h5p::$interface;
43
        $usage = $interface->getLibraryUsage($this->id, $interface->getNumNotFiltered() ? true : false);
44
45
        return intval($usage['content']);
46
    }
47
48
    public function getCountLibraryDependencies()
49
    {
50
        $h5p = App::make('LaravelH5p');
51
        $interface = $h5p::$interface;
52
        $usage = $interface->getLibraryUsage($this->id, $interface->getNumNotFiltered() ? true : false);
53
54
        return intval($usage['libraries']);
55
    }
56
}
57