44namespace PleskX \Api \Operator ;
55
66use PleskX \Api \Struct \Database as Struct ;
7+ use PleskX \Api \XmlResponse ;
78
89class Database extends \PleskX \Api \Operator
910{
10- /**
11- * @param array $properties
12- *
13- * @return Struct\Info
14- */
15- public function create ($ properties )
11+ public function create (array $ properties ): Struct \Info
1612 {
1713 return new Struct \Info ($ this ->process ('add-db ' , $ properties ));
1814 }
1915
20- /**
21- * @param array $properties
22- *
23- * @return Struct\UserInfo
24- */
25- public function createUser ($ properties )
16+ public function createUser (array $ properties ): Struct \UserInfo
2617 {
2718 return new Struct \UserInfo ($ this ->process ('add-db-user ' , $ properties ));
2819 }
2920
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
3722 {
3823 $ packet = $ this ->client ->getPacket ();
3924 $ info = $ packet ->addChild ($ this ->wrapperTag )->addChild ($ command );
@@ -49,12 +34,7 @@ private function process($command, array $properties)
4934 return $ this ->client ->request ($ packet );
5035 }
5136
52- /**
53- * @param array $properties
54- *
55- * @return bool
56- */
57- public function updateUser (array $ properties )
37+ public function updateUser (array $ properties ): bool
5838 {
5939 $ response = $ this ->process ('set-db-user ' , $ properties );
6040
@@ -67,7 +47,7 @@ public function updateUser(array $properties)
6747 *
6848 * @return Struct\Info
6949 */
70- public function get ($ field , $ value )
50+ public function get (string $ field , $ value ): Struct \ Info
7151 {
7252 $ items = $ this ->getAll ($ field , $ value );
7353
@@ -80,7 +60,7 @@ public function get($field, $value)
8060 *
8161 * @return Struct\UserInfo
8262 */
83- public function getUser ($ field , $ value )
63+ public function getUser (string $ field , $ value ): Struct \ UserInfo
8464 {
8565 $ items = $ this ->getAllUsers ($ field , $ value );
8666
@@ -93,7 +73,7 @@ public function getUser($field, $value)
9373 *
9474 * @return Struct\Info[]
9575 */
96- public function getAll ($ field , $ value )
76+ public function getAll (string $ field , $ value ): array
9777 {
9878 $ response = $ this ->getBy ('get-db ' , $ field , $ value );
9979 $ items = [];
@@ -110,7 +90,7 @@ public function getAll($field, $value)
11090 *
11191 * @return Struct\UserInfo[]
11292 */
113- public function getAllUsers ($ field , $ value )
93+ public function getAllUsers (string $ field , $ value ): array
11494 {
11595 $ response = $ this ->getBy ('get-db-users ' , $ field , $ value );
11696 $ items = [];
@@ -126,9 +106,9 @@ public function getAllUsers($field, $value)
126106 * @param string $field
127107 * @param int|string $value
128108 *
129- * @return \PleskX\Api\ XmlResponse
109+ * @return XmlResponse
130110 */
131- private function getBy (string $ command , string $ field , $ value )
111+ private function getBy (string $ command , string $ field , $ value ): XmlResponse
132112 {
133113 $ packet = $ this ->client ->getPacket ();
134114 $ getTag = $ packet ->addChild ($ this ->wrapperTag )->addChild ($ command );
@@ -145,7 +125,7 @@ private function getBy(string $command, string $field, $value)
145125 *
146126 * @return bool
147127 */
148- public function delete ($ field , $ value )
128+ public function delete (string $ field , $ value ): bool
149129 {
150130 return $ this ->deleteBy ($ field , $ value , 'del-db ' );
151131 }
@@ -156,7 +136,7 @@ public function delete($field, $value)
156136 *
157137 * @return bool
158138 */
159- public function deleteUser ($ field , $ value )
139+ public function deleteUser (string $ field , $ value ): bool
160140 {
161141 return $ this ->deleteBy ($ field , $ value , 'del-db-user ' );
162142 }
0 commit comments