1 | <?php |
||
18 | class Factory |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * @var NetworkInterface |
||
23 | */ |
||
24 | private $network; |
||
25 | |||
26 | /** |
||
27 | * @var LoopInterface |
||
28 | */ |
||
29 | 18 | private $loop; |
|
30 | |||
31 | 18 | private $messages = null; |
|
32 | 18 | ||
33 | 18 | /** |
|
34 | * @param NetworkInterface $network |
||
35 | * @param LoopInterface $loop |
||
36 | */ |
||
37 | public function __construct(LoopInterface $loop, NetworkInterface $network = null) |
||
38 | { |
||
39 | 18 | $this->loop = $loop; |
|
40 | $this->network = $network ?: Bitcoin::getNetwork(); |
||
41 | 18 | $this->settings = new Settings\MainnetSettings(); |
|
|
|||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @return Dns\Resolver |
||
46 | */ |
||
47 | public function getDns() |
||
51 | 12 | ||
52 | 12 | /** |
|
53 | 8 | * @param Random|null $random |
|
54 | * @return Messages\Factory |
||
55 | */ |
||
56 | public function getMessages(Random $random = null) |
||
66 | 4 | ||
67 | /** |
||
68 | 4 | * @param Settings\NetworkSettings $settings |
|
69 | */ |
||
70 | public function setSettings(Settings\NetworkSettings $settings) |
||
74 | |||
75 | /** |
||
76 | * @return Settings\NetworkSettings |
||
77 | */ |
||
78 | public function getSettings() |
||
82 | |||
83 | /** |
||
84 | * @param Peer\ConnectionParams $params |
||
85 | * @return Peer\Connector |
||
86 | */ |
||
87 | public function getConnector(Peer\ConnectionParams $params) |
||
91 | |||
92 | /** |
||
93 | * @param Peer\Connector $connector |
||
94 | * @return Peer\Manager |
||
95 | */ |
||
96 | public function getManager(Peer\Connector $connector) |
||
100 | |||
101 | /** |
||
102 | * @return Peer\Locator |
||
103 | */ |
||
104 | public function getLocator() |
||
108 | |||
109 | /** |
||
110 | * @param ConnectionParams $params |
||
111 | * @param NetworkAddressInterface $serverAddress |
||
112 | * @return Listener |
||
113 | */ |
||
114 | public function getListener(Peer\ConnectionParams $params, NetworkAddressInterface $serverAddress) |
||
118 | |||
119 | /** |
||
120 | * @param IpInterface $ipAddress |
||
121 | * @param int $port |
||
122 | * @param int $services |
||
123 | * @return NetworkAddress |
||
124 | */ |
||
125 | public function getAddress(IpInterface $ipAddress, $port = 8333, $services = Services::NONE) |
||
133 | } |
||
134 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: