InitRepository::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 11
rs 10
1
<?php
2
3
namespace App\Repositories;
4
5
use Config;
6
7
abstract class InitRepository
8
{
9
    protected $model;
10
    private $cache_enabled;
11
    protected $cache_time_forever;
12
13
    abstract protected function getModelClass();
14
15
    public function __construct()
16
    {
17
        //длительность кеша
18
        $this->cache_time_forever = (int) Config::get('app.cache_time_forever');
19
        $this->cache_enabled = (bool) Config::get('app.cache_enabled');
20
21
        $this->model = app($this->getModelClass());
22
23
        // Enable/disable cache repo
24
        if (!$this->cache_enabled) {
25
            $this->cache_time_forever = 0;
26
        }
27
    }
28
29
    protected function startConditions()
30
    {
31
        return clone $this->model;
32
    }
33
}
34