Completed
Push — master ( 09b86b...ba0798 )
by Andreas
20:05 queued 12s
created

PersistentCollection::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 0
Metric Value
dl 9
loc 9
ccs 6
cts 7
cp 0.8571
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2.0116
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ODM\MongoDB;
6
7
use Doctrine\Common\Collections\Collection as BaseCollection;
8
use Doctrine\ODM\MongoDB\PersistentCollection\PersistentCollectionInterface;
9
use Doctrine\ODM\MongoDB\PersistentCollection\PersistentCollectionTrait;
10
use const E_USER_DEPRECATED;
11
use function sprintf;
12
use function trigger_error;
13
14
/**
15
 * A PersistentCollection represents a collection of elements that have persistent state.
16
 *
17
 * @final
18
 */
19
class PersistentCollection implements PersistentCollectionInterface
20
{
21
    use PersistentCollectionTrait;
22
23
    /**
24
     * @param BaseCollection $coll
25
     */
26 443 View Code Duplication
    public function __construct(BaseCollection $coll, DocumentManager $dm, UnitOfWork $uow)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28 443
        if (self::class !== static::class) {
29
            @trigger_error(sprintf('The class "%s" extends "%s" which will be final in MongoDB ODM 2.0.', static::class, self::class), E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
30
        }
31 443
        $this->coll = $coll;
32 443
        $this->dm   = $dm;
33 443
        $this->uow  = $uow;
34 443
    }
35
}
36