Completed
Pull Request — 1.0 (#58)
by Titouan
04:38 queued 02:05
created

NullRepository::setChangeStream()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 1
nc 1
nop 1
crap 2
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\ChangeStream\ChangeStream;
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 4
    public function add($path, $resource)
36
    {
37 4
    }
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
    public function getStack($path)
65
    {
66
        throw ResourceNotFoundException::forPath($path);
67
    }
68
69
    /**
70
     * @param ChangeStream $changeStream
0 ignored issues
show
Documentation introduced by
Should the type for parameter $changeStream not be null|ChangeStream?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
71
     */
72
    public function setChangeStream(ChangeStream $changeStream = null)
0 ignored issues
show
Unused Code introduced by
The parameter $changeStream is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
73
    {
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79 1
    public function find($query, $language = 'glob')
80
    {
81 1
        return new ArrayResourceCollection();
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87 2
    public function contains($query, $language = 'glob')
88
    {
89 2
        return false;
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95 1
    public function hasChildren($path)
96
    {
97 1
        return false;
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103 1
    public function listChildren($path)
104
    {
105 1
        return new ArrayResourceCollection();
106
    }
107
}
108