Skip to content

Commit 0e9dc34

Browse files
Add comments
1 parent c7ca0e5 commit 0e9dc34

File tree

5 files changed

+50
-8
lines changed

5 files changed

+50
-8
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# PHP SDK for Nginx Unit
1+
# PHP SDK for Nginx Unit
22

3-
## Installation
3+
_THIS PROJECT IN DEVELOPMENT. DON'T USE IT IN PRODUCTION_
44

5+
## Quick start
56
```shell
6-
composer install
7+
composer require pavlusha311245/unit-php-sdk
78
```
8-

src/Config.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class Config implements ConfigInterface
1818
private array $_upstreams;
1919

2020
/**
21+
* Constructor
22+
*
2123
* @throws \Exception
2224
*/
2325
public function __construct(array $data)
@@ -45,26 +47,53 @@ public function __construct(array $data)
4547
$this->_upstreams = $data['upstreams'] ?? [];
4648
}
4749

50+
/**
51+
* Get listeners from config
52+
*
53+
* @return array
54+
*/
4855
public function getListeners(): array
4956
{
5057
return $this->_listeners ?? [];
5158
}
5259

60+
/**
61+
* Get applications from config
62+
*
63+
* @return array
64+
*/
5365
public function getApplications(): array
5466
{
5567
return $this->_applications;
5668
}
5769

70+
/**
71+
* Get application from config by name
72+
*
73+
* @param $applicationName
74+
* @return mixed
75+
*/
5876
public function getApplication($applicationName)
5977
{
6078
return $this->_applications[$applicationName];
6179
}
6280

81+
/**
82+
* Get routes from config
83+
*
84+
* @return array
85+
*/
6386
public function getRoutes(): array
6487
{
6588
return $this->_routes;
6689
}
6790

91+
/**
92+
* Get route from config by name
93+
*
94+
* @param $routeName
95+
* @return mixed
96+
*/
6897
public function getRoute($routeName)
6998
{
7099
return $this->_routes[$routeName];
@@ -78,6 +107,11 @@ public function getUpstreams(): mixed
78107
return $this->_upstreams;
79108
}
80109

110+
/**
111+
* Return config as array
112+
*
113+
* @return array
114+
*/
81115
public function toArray(): array
82116
{
83117
return [

src/Config/Application.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Application
2828

2929
private $_data;
3030

31-
private array $_arguments;
31+
private array $_arguments = [];
3232

3333
private array $_listeners = [];
3434

@@ -37,6 +37,7 @@ public function __construct($applicationName, $applicationData)
3737
$this->_name = $applicationName;
3838
$this->_type = $applicationData['type'];
3939
$this->_data = $applicationData;
40+
4041
foreach ($this->_data as $key => $value) {
4142
$this->{"_{$key}"} = $value;
4243
}
@@ -47,7 +48,7 @@ public function __construct($applicationName, $applicationData)
4748
*/
4849
public function getArguments(): array
4950
{
50-
return $this->_arguments;
51+
return array_values($this->_arguments);
5152
}
5253

5354
public function getType(): string
@@ -56,7 +57,7 @@ public function getType(): string
5657
}
5758

5859
/**
59-
* @param mixed $listener
60+
* @param mixed $listener
6061
*/
6162
public function setListener(Listener $listener): void
6263
{

src/Interfaces/ConfigInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ public function getListeners();
88

99
public function getRoutes();
1010

11+
public function getRoute($routeName);
12+
1113
public function getApplications();
1214

15+
public function getApplication($applicationName);
16+
1317
public function getUpstreams();
1418

1519
public function toArray(): array;

src/UnitRequest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ class UnitRequest
88

99
private $_data = null;
1010

11-
public function __construct(private string $socket, private string $address)
11+
public function __construct(
12+
private string $socket,
13+
private string $address
14+
)
1215
{
1316
//
1417
}

0 commit comments

Comments
 (0)