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:
8: namespace Nette\PhpGenerator\Traits;
9:
10: use Nette;
11:
12:
13: /**
14: * @internal
15: */
16: trait NameAware
17: {
18: /** @var string */
19: private $name;
20:
21:
22: /**
23: * @param string
24: */
25: public function __construct($name)
26: {
27: if (!Nette\PhpGenerator\Helpers::isIdentifier($name)) {
28: throw new Nette\InvalidArgumentException("Value '$name' is not valid name.");
29: }
30: $this->name = $name;
31: }
32:
33:
34: /** @deprecated */
35: public function setName($name)
36: {
37: trigger_error(__METHOD__ . '() is deprecated, use constructor.', E_USER_DEPRECATED);
38: $this->__construct($name);
39: return $this;
40: }
41:
42:
43: /**
44: * @return string
45: */
46: public function getName()
47: {
48: return $this->name;
49: }
50: }
51: