PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.7.0
Defender Security – Malware Scanner, Login Security & Firewall v5.7.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / lib / packages / DI / Definition / Reference.php

Reference.php in Defender Security – Malware Scanner, Login Security & Firewall 5.7.0, at lib/packages/DI/Definition/Reference.php

65 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WPMU_DEV\Defender\Vendor\DI\Definition;
6
7 use WPMU_DEV\Defender\Vendor\Psr\Container\ContainerInterface;
8
9 /**
10 * Represents a reference to another entry.
11 *
12 * @author Matthieu Napoli <[email protected]>
13 */
14 class Reference implements Definition, SelfResolvingDefinition
15 {
16 /** Entry name. */
17 private string $name = '';
18
19 /**
20 * @param string $targetEntryName Name of the target entry
21 */
22 public function __construct(
23 private string $targetEntryName,
24 ) {
25 }
26
27 public function getName() : string
28 {
29 return $this->name;
30 }
31
32 public function setName(string $name) : void
33 {
34 $this->name = $name;
35 }
36
37 public function getTargetEntryName() : string
38 {
39 return $this->targetEntryName;
40 }
41
42 public function resolve(ContainerInterface $container) : mixed
43 {
44 return $container->get($this->getTargetEntryName());
45 }
46
47 public function isResolvable(ContainerInterface $container) : bool
48 {
49 return $container->has($this->getTargetEntryName());
50 }
51
52 public function replaceNestedDefinitions(callable $replacer) : void
53 {
54 // no nested definitions
55 }
56
57 public function __toString() : string
58 {
59 return sprintf(
60 'get(%s)',
61 $this->targetEntryName
62 );
63 }
64 }
65