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

CachePrefixing::getCachePrefix()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
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