Failed Conditions
Pull Request — 1.0 (#79)
by Bernhard
02:44
created

NullRepository   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 88.89%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 9
c 2
b 0
f 2
lcom 0
cbo 2
dl 0
loc 71
ccs 16
cts 18
cp 0.8889
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 3 1
A remove() 0 3 1
A clear() 0 3 1
A get() 0 4 1
A contains() 0 4 1
A hasChildren() 0 4 1
A listChildren() 0 4 1
A find() 0 4 1
A getStack() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the puli/repository package.
5
 *
6
 * (c) Bernhard Schussek <[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 Puli\Repository;
13
14
use Puli\Repository\Api\EditableRepository;
15
use Puli\Repository\Api\ResourceNotFoundException;
16
use Puli\Repository\Resource\Collection\ArrayResourceCollection;
17
18
/**
19
 * A repository that does nothing.
20
 *
21
 * This repository can be used if you need to inject a repository instance in
22
 * some code, but you don't want that repository to do anything (for example
23
 * in tests).
24
 *
25
 * @since  1.0
26
 *
27
 * @author Bernhard Schussek <[email protected]>
28
 */
29
class NullRepository implements EditableRepository
30
{
31
    /**
32
     * {@inheritdoc}
33
     */
34 5
    public function add($path, $resource)
35
    {
36 5
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 1
    public function remove($query, $language = 'glob')
42
    {
43 1
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function clear()
49
    {
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55 1
    public function get($path)
56
    {
57 1
        throw ResourceNotFoundException::forPath($path);
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63 1
    public function getStack($path)
64
    {
65 1
        throw ResourceNotFoundException::forPath($path);
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71 1
    public function find($query, $language = 'glob')
72
    {
73 1
        return new ArrayResourceCollection();
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79 2
    public function contains($query, $language = 'glob')
80
    {
81 2
        return false;
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87 1
    public function hasChildren($path)
88
    {
89 1
        return false;
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95 1
    public function listChildren($path)
96
    {
97 1
        return new ArrayResourceCollection();
98
    }
99
}
100