Failed Conditions
Push — 1.0 ( 9f5a0b...fe7a2f )
by Bernhard
30:36 queued 17:00
created

NullRepository   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 88.89%

Importance

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