InitRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A startConditions() 0 3 1
A __construct() 0 11 2
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