Entity::setRepositoryClass()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace LaravelDoctrine\Fluent\Builders;
4
5
use Doctrine\ORM\Mapping\ClassMetadataInfo;
6
7
class Entity extends AbstractBuilder
8
{
9
    /**
10
     * @param string $class
11
     *
12
     * @return Entity
13
     */
14 1
    public function setRepositoryClass($class)
15
    {
16 1
        $this->builder->setCustomRepositoryClass($class);
17
18 1
        return $this;
19
    }
20
21
    /**
22
     * @return Entity
23
     */
24 1
    public function readOnly()
25
    {
26 1
        $this->builder->setReadOnly();
27
28 1
        return $this;
29
    }
30
31
    /**
32
     * Enables second-level cache on this entity.
33
     * If you want to enable second-level cache,
34
     * you must enable it on the EntityManager configuration.
35
     * Depending on the cache mode selected, you may also need to configure
36
     * lock modes.
37
     *
38
     * @param int         $usage  Cache mode. use ClassMetadataInfo::CACHE_USAGE_* constants.
39
     *                            Defaults to READ_ONLY mode.
40
     * @param string|null $region The cache region to be used. Doctrine will use a default region
41
     *                            for each entity, if none is provided.
42
     *
43
     * @return Entity
44
     * @see http://doctrine-orm.readthedocs.org/en/latest/reference/second-level-cache.html
45
     */
46 1
    public function cacheable($usage = ClassMetadataInfo::CACHE_USAGE_READ_ONLY, $region = null)
47
    {
48 1
        $meta = $this->builder->getClassMetadata();
49 1
        $meta->enableCache(compact('usage', $region === null ?: 'region'));
50
51 1
        return $this;
52
    }
53
}
54