MappedStatementRepository::findMappedStatement()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the xAPI package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Xabbuh\XApi\Storage\MongoDB\Repository;
13
14
use Doctrine\ODM\MongoDB\DocumentRepository;
15
use Xabbuh\XApi\Storage\Api\Mapping\MappedStatement;
16
use Xabbuh\XApi\Storage\Doctrine\Repository\MappedStatementRepository as MappedStatementRepositoryInteface;
17
18
/**
19
 * A MongoDB backed statement repository.
20
 *
21
 * @author Christian Flothmann <[email protected]>
22
 */
23
class MappedStatementRepository extends DocumentRepository implements MappedStatementRepositoryInteface
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function findMappedStatement(array $criteria)
29
    {
30
        return parent::findOneBy($criteria);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (findOneBy() instead of findMappedStatement()). Are you sure this is correct? If so, you might want to change this to $this->findOneBy().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function findMappedStatements(array $criteria)
37
    {
38
        return parent::findBy($criteria);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (findBy() instead of findMappedStatements()). Are you sure this is correct? If so, you might want to change this to $this->findBy().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function storeMappedStatement(MappedStatement $mappedStatement, $flush = true)
45
    {
46
        $this->getDocumentManager()->persist($mappedStatement);
47
48
        if ($flush) {
49
            $this->getDocumentManager()->flush();
50
        }
51
    }
52
}
53