NamingDirectoryWrapper::search()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
/**
4
 * \AppserverIo\Psr\Naming\NamingDirectoryWrapper
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2015 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io-psr/naming
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\Psr\Naming;
22
23
/**
24
 * A naming directory wrapper implementation.
25
 *
26
 * @author    Tim Wagner <[email protected]>
27
 * @copyright 2015 TechDivision GmbH <[email protected]>
28
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
 * @link      https://github.com/appserver-io-psr/naming
30
 * @link      http://www.appserver.io
31
 */
32
class NamingDirectoryWrapper
33
{
34
35
    /**
36
     * The naming directory instance.
37
     *
38
     * @var \AppserverIo\Psr\Naming\NamingDirectoryInterface
39
     */
40
    protected $namingDirectory;
41
42
    /**
43
     * Injects the passed naming directory instance into this naming directory wrapper.
44
     *
45
     * @param \AppserverIo\Psr\Naming\NamingDirectoryInterface $namingDirectory The naming directory instance used for initialization
46
     *
47
     * @return void
48
     */
49 1
    public function injectNamingDirectory(NamingDirectoryInterface $namingDirectory)
50
    {
51 1
        $this->namingDirectory = $namingDirectory;
52 1
    }
53
54
    /**
55
     * Returns the naming directory instance.
56
     *
57
     * @return \AppserverIo\Psr\Naming\NamingDirectoryInterface The naming directory instance
58
     */
59 1
    public function getNamingDirectory()
60
    {
61 1
        return $this->namingDirectory;
62
    }
63
64
    /**
65
     * Returns the directory name.
66
     *
67
     * @return string The directory name
68
     */
69 1
    public function getName()
70
    {
71 1
        return $this->getNamingDirectory()->getName();
72
    }
73
74
    /**
75
     * Returns the parent directory.
76
     *
77
     * @return \AppserverIo\Psr\Naming\NamingDirectoryInterface
78
     */
79
    public function getParent()
80
    {
81
        return $this->getNamingDirectory()->getParent();
82
    }
83
84
    /**
85
     * Returns the scheme.
86
     *
87
     * @return string The scheme we want to use
88
     */
89
    public function getScheme()
90
    {
91
        return $this->getNamingDirectory()->getScheme();
92
    }
93
94
    /**
95
     * Binds the passed instance with the name to the naming directory.
96
     *
97
     * @param string $name  The name to bind the object with
98
     * @param object $value The object instance to bind
99
     * @param array  $args  The array with the arguments
100
     *
101
     * @return void
102
     */
103
    public function bind($name, $value, array $args = array())
104
    {
105
        $this->getNamingDirectory()->bind($name, $value, $args);
106
    }
107
108
    /**
109
     * Binds the passed callback with the name to the naming directory.
110
     *
111
     * @param string   $name     The name to bind the callback with
112
     * @param callable $callback The callback to be invoked when searching for
113
     * @param array    $args     The array with the arguments passed to the callback when executed
114
     *
115
     * @return void
116
     * @see \AppserverIo\Psr\Naming\NamingDirectoryInterface::bind()
117
     */
118
    public function bindCallback($name, callable $callback, array $args = array())
119
    {
120
        $this->getNamingDirectory()->bindCallback($name, $callback, $args);
121
    }
122
123
124
    /**
125
     * Queries the naming directory for the requested name and returns the value
126
     * or invokes the bound callback.
127
     *
128
     * @param string $name The name of the requested value
129
     * @param array  $args The arguments to pass to the callback
130
     *
131
     * @return mixed The requested value
132
     * @throws \AppserverIo\Psr\Naming\NamingException Is thrown if the requested name can't be resolved in the directory
133
     */
134
    public function search($name, array $args = array())
135
    {
136
        return $this->getNamingDirectory()->search($name, $args);
137
    }
138
139
    /**
140
     * Create and return a new naming subdirectory with the attributes
141
     * of this one.
142
     *
143
     * @param string $name   The name of the new subdirectory
144
     * @param array  $filter Array with filters that will be applied when copy the attributes
145
     *
146
     * @return \AppserverIo\Psr\Naming\NamingDirectoryInterface The new naming subdirectory
147
     */
148
    public function createSubdirectory($name, array $filter = array())
149
    {
150
        return $this->getNamingDirectory()->createSubdirectory($name, $filter);
151
    }
152
}
153