Failed Conditions
Push — develop ( 9800ca...d1cf9a )
by Marco
272:19 queued 264:21
created

ReadOnlyCachedCollectionPersister::update()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 2
nop 1
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 3
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
4
declare(strict_types=1);
5
6
namespace Doctrine\ORM\Cache\Persister\Collection;
7
8
use Doctrine\ORM\Cache\CacheException;
9
use Doctrine\ORM\PersistentCollection;
10
use Doctrine\ORM\Utility\StaticClassNameConverter;
11
12
/**
13
 * @author Fabio B. Silva <[email protected]>
14
 * @since 2.5
15
 */
16
class ReadOnlyCachedCollectionPersister extends NonStrictReadWriteCachedCollectionPersister
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21 23
    public function update(PersistentCollection $collection)
22
    {
23 23
        if ($collection->isDirty() && $collection->getSnapshot()) {
24 1
            throw CacheException::updateReadOnlyCollection(
25 1
                StaticClassNameConverter::getClass($collection->getOwner()),
26 1
                $this->association->getName()
27
            );
28
        }
29
30 23
        parent::update($collection);
31 23
    }
32
}
33