StaticContentRepository   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A findPublishedOneByName() 0 11 3
1
<?php
2
3
namespace Lakion\CmsPlugin\Repository;
4
5
use Doctrine\ODM\PHPCR\DocumentManagerInterface;
6
use Doctrine\ODM\PHPCR\Mapping\ClassMetadata;
7
use Lakion\CmsPlugin\Document\StaticContent;
8
use Sylius\Bundle\ResourceBundle\Doctrine\ODM\PHPCR\DocumentRepository;
9
10
class StaticContentRepository extends DocumentRepository implements StaticContentRepositoryInterface
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: find, findAll, findBy, findOneBy, getClassName
Loading history...
11
{
12
    /**
13
     * @var string
14
     */
15
    private $staticContentPath;
16
17
    /**
18
     * @param DocumentManagerInterface $dm
19
     * @param ClassMetadata $class
20
     * @param string $staticContentPath
21
     */
22
    public function __construct(DocumentManagerInterface $dm, ClassMetadata $class, $staticContentPath)
23
    {
24
        parent::__construct($dm, $class);
25
26
        $this->staticContentPath = $staticContentPath;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function findPublishedOneByName($name)
33
    {
34
        /** @var StaticContent|null $staticContent */
35
        $staticContent = $this->find($this->staticContentPath . '/' . $name);
36
37
        if (null === $staticContent || !$staticContent->isPublishable()) {
38
            return null;
39
        }
40
41
        return $staticContent;
42
    }
43
}
44