Passed
Push — master ( 789493...b9494e )
by Mike
02:25
created

CachePrefixing   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDatabaseConnectionName() 0 3 1
A getDatabaseName() 0 3 1
A getCachePrefix() 0 8 2
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->getDatabaseConnectionName() . ":"
9
            . $this->getDatabaseName() . ":"
10
            . (config("laravel-model-caching.cache-prefix")
11
                ? config("laravel-model-caching.cache-prefix", "") . ":"
12
                : "");
13
    }
14
15
    protected function getDatabaseConnectionName() : string
16
    {
17
        return $this->query->connection->getName();
18
    }
19
20
    protected function getDatabaseName() : string
21
    {
22
        return $this->query->connection->getDatabaseName();
23
    }
24
}
25