4
4
namespace PleskX \Api \Operator ;
5
5
6
6
use PleskX \Api \Struct \Database as Struct ;
7
+ use PleskX \Api \XmlResponse ;
7
8
8
9
class Database extends \PleskX \Api \Operator
9
10
{
10
- /**
11
- * @param array $properties
12
- *
13
- * @return Struct\Info
14
- */
15
- public function create ($ properties )
11
+ public function create (array $ properties ): Struct \Info
16
12
{
17
13
return new Struct \Info ($ this ->process ('add-db ' , $ properties ));
18
14
}
19
15
20
- /**
21
- * @param array $properties
22
- *
23
- * @return Struct\UserInfo
24
- */
25
- public function createUser ($ properties )
16
+ public function createUser (array $ properties ): Struct \UserInfo
26
17
{
27
18
return new Struct \UserInfo ($ this ->process ('add-db-user ' , $ properties ));
28
19
}
29
20
30
- /**
31
- * @param string $command
32
- * @param array $properties
33
- *
34
- * @return \PleskX\Api\XmlResponse
35
- */
36
- private function process ($ command , array $ properties )
21
+ private function process (string $ command , array $ properties ): XmlResponse
37
22
{
38
23
$ packet = $ this ->client ->getPacket ();
39
24
$ info = $ packet ->addChild ($ this ->wrapperTag )->addChild ($ command );
@@ -49,12 +34,7 @@ private function process($command, array $properties)
49
34
return $ this ->client ->request ($ packet );
50
35
}
51
36
52
- /**
53
- * @param array $properties
54
- *
55
- * @return bool
56
- */
57
- public function updateUser (array $ properties )
37
+ public function updateUser (array $ properties ): bool
58
38
{
59
39
$ response = $ this ->process ('set-db-user ' , $ properties );
60
40
@@ -67,7 +47,7 @@ public function updateUser(array $properties)
67
47
*
68
48
* @return Struct\Info
69
49
*/
70
- public function get ($ field , $ value )
50
+ public function get (string $ field , $ value ): Struct \ Info
71
51
{
72
52
$ items = $ this ->getAll ($ field , $ value );
73
53
@@ -80,7 +60,7 @@ public function get($field, $value)
80
60
*
81
61
* @return Struct\UserInfo
82
62
*/
83
- public function getUser ($ field , $ value )
63
+ public function getUser (string $ field , $ value ): Struct \ UserInfo
84
64
{
85
65
$ items = $ this ->getAllUsers ($ field , $ value );
86
66
@@ -93,7 +73,7 @@ public function getUser($field, $value)
93
73
*
94
74
* @return Struct\Info[]
95
75
*/
96
- public function getAll ($ field , $ value )
76
+ public function getAll (string $ field , $ value ): array
97
77
{
98
78
$ response = $ this ->getBy ('get-db ' , $ field , $ value );
99
79
$ items = [];
@@ -110,7 +90,7 @@ public function getAll($field, $value)
110
90
*
111
91
* @return Struct\UserInfo[]
112
92
*/
113
- public function getAllUsers ($ field , $ value )
93
+ public function getAllUsers (string $ field , $ value ): array
114
94
{
115
95
$ response = $ this ->getBy ('get-db-users ' , $ field , $ value );
116
96
$ items = [];
@@ -126,9 +106,9 @@ public function getAllUsers($field, $value)
126
106
* @param string $field
127
107
* @param int|string $value
128
108
*
129
- * @return \PleskX\Api\ XmlResponse
109
+ * @return XmlResponse
130
110
*/
131
- private function getBy (string $ command , string $ field , $ value )
111
+ private function getBy (string $ command , string $ field , $ value ): XmlResponse
132
112
{
133
113
$ packet = $ this ->client ->getPacket ();
134
114
$ getTag = $ packet ->addChild ($ this ->wrapperTag )->addChild ($ command );
@@ -145,7 +125,7 @@ private function getBy(string $command, string $field, $value)
145
125
*
146
126
* @return bool
147
127
*/
148
- public function delete ($ field , $ value )
128
+ public function delete (string $ field , $ value ): bool
149
129
{
150
130
return $ this ->deleteBy ($ field , $ value , 'del-db ' );
151
131
}
@@ -156,7 +136,7 @@ public function delete($field, $value)
156
136
*
157
137
* @return bool
158
138
*/
159
- public function deleteUser ($ field , $ value )
139
+ public function deleteUser (string $ field , $ value ): bool
160
140
{
161
141
return $ this ->deleteBy ($ field , $ value , 'del-db-user ' );
162
142
}
0 commit comments