Completed
Push — master ( 29a90d...0e040f )
by Mike
03:08
created

CachePrefixing   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCachePrefix() 0 8 2
A getDatabaseName() 0 3 1
A getConnectionName() 0 3 1
1
<?php namespace GeneaLabs\LaravelModelCaching\Traits;
2
3
trait CachePrefixing
4
{
5
    protected function getCachePrefix() : string
6
    {
7
        return "genealabs:laravel-model-caching:"
8
            . $this->getConnectionName() . ":"
9
            . $this->getDatabaseName() . ":"
10
            . (config("laravel-model-caching.cache-prefix")
11
                ? config("laravel-model-caching.cache-prefix", "") . ":"
12
                : "");
13
    }
14
15
    protected function getDatabaseName() : string
16
    {
17
        return $this->query->connection->getDatabaseName();
18
    }
19
20
    protected function getConnectionName() : string
21
    {
22
        return $this->model->getConnection()->getName();
23
    }
24
}
25