PluginProbe
Packeta / 2.1
Packeta v2.1
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / deps / nette / di / src / DI / Definitions / Reference.php

Reference.php in Packeta 2.1, at deps/nette/di/src/DI/Definitions/Reference.php

50 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * This file is part of the Nette Framework (https://nette.org)
5 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6 */
7 declare (strict_types=1);
8 namespace Packetery\Nette\DI\Definitions;
9
10 use Packetery\Nette;
11 /**
12 * Reference to service. Either by name or by type or reference to the 'self' service.
13 */
14 final class Reference
15 {
16 use \Packetery\Nette\SmartObject;
17 public const Self = 'self';
18 /** @deprecated use Reference::Self */
19 public const SELF = self::Self;
20 /** @var string */
21 private $value;
22 public static function fromType(string $value) : self
23 {
24 if (\strpos($value, '\\') === \false) {
25 $value = '\\' . $value;
26 }
27 return new static($value);
28 }
29 public function __construct(string $value)
30 {
31 $this->value = $value;
32 }
33 public function getValue() : string
34 {
35 return $this->value;
36 }
37 public function isName() : bool
38 {
39 return \strpos($this->value, '\\') === \false && $this->value !== self::Self;
40 }
41 public function isType() : bool
42 {
43 return \strpos($this->value, '\\') !== \false;
44 }
45 public function isSelf() : bool
46 {
47 return $this->value === self::Self;
48 }
49 }
50