55use Qonsillium \Credential \SocketCredentials ;
66use Qonsillium \Actions \{
77 SocketAcceptor ,
8- SocketBinder ,
98 SocketCloser ,
109 SocketConnector ,
11- SocketCreator ,
12- SocketListener ,
1310 SocketReader ,
1411 SocketWriter
1512};
@@ -33,93 +30,20 @@ public function __construct(SocketCredentials $credentials)
3330 }
3431
3532 /**
36- * Returns socket domain setting from config file
33+ * Returns socket connection address
3734 * @return string
3835 */
39- private function getDomain ()
36+ public function getAddress ()
4037 {
41- return $ this ->credentials ->getCredential ('domain ' );
42- }
43-
44- /**
45- * Returns socket type setting from config file
46- * @return string
47- */
48- private function getType ()
49- {
50- return $ this ->credentials ->getCredential ('type ' );
51- }
52-
53- /**
54- * Returns socket protocol setting from config file
55- * @return string
56- */
57- private function getProtocol ()
58- {
59- return $ this ->credentials ->getCredential ('protocol ' );
60- }
61-
62- /**
63- * Return setted host or socket file name from
64- * credentials handler
65- * @return string
66- */
67- private function getAddress ()
68- {
69- if ($ this ->credentials ->validateExistence ('socket_file ' )) {
70- return $ this ->credentials ->getCredential ('socket_file ' );
71- }
72-
7338 return $ this ->credentials ->getCredential ('host ' );
7439 }
7540
7641 /**
77- * Return setted socket port from
78- * credentials handler
79- * @return string
80- */
81- private function getPort ()
82- {
83- if ($ this ->credentials ->validateExistence ('port ' )) {
84- return $ this ->credentials ->getCredential ('port ' );
85- }
86-
87- return 0 ;
88- }
89-
90- /**
91- * Returns number of incoming backlogs
92- * @return int
93- */
94- private function getBacklog ()
95- {
96- return $ this ->credentials ->getCredential ('backlog ' );
97- }
98-
99- /**
100- * Bytes length which will be fetched from remote host
101- * @return int
102- */
103- private function getReadLength ()
104- {
105- return $ this ->credentials ->getCredential ('read_length ' );
106- }
107-
108- /**
109- * Return flag value responded for reading status
110- * @return int
111- */
112- private function getReadFlag ()
113- {
114- return $ this ->credentials ->getCredential ('read_flag ' );
115- }
116-
117- /**
118- * @return \Qonsillium\Actions\SocketCreator
42+ * @return \Qonsillium\Actions\SocketConnector
11943 */
120- public function getCreator (): SocketCreator
44+ public function getConnector ( string $ type )
12145 {
122- return new SocketCreator ($ this ->getDomain (), $ this -> getType (), $ this -> getProtocol () );
46+ return new SocketConnector ($ this ->getAddress (), $ type );
12347 }
12448
12549 /**
@@ -130,36 +54,12 @@ public function getAcceptor(): SocketAcceptor
13054 return new SocketAcceptor ();
13155 }
13256
133- /**
134- * @return \Qonsillium\Actions\SocketConnector
135- */
136- public function getConnector (): SocketConnector
137- {
138- return new SocketConnector ($ this ->getAddress (), $ this ->getPort ());
139- }
140-
141- /**
142- * @return \Qonsillium\Actions\SocketListener
143- */
144- public function getListener (): SocketListener
145- {
146- return new SocketListener ($ this ->getBacklog ());
147- }
148-
149- /**
150- * @return \Qonsillium\Actions\SocketBinder
151- */
152- public function getBinder (): SocketBinder
153- {
154- return new SocketBinder ($ this ->getAddress (), $ this ->getPort ());
155- }
156-
15757 /**
15858 * @return \Qonsillium\Actions\SocketReader
15959 */
16060 public function getReader (): SocketReader
16161 {
162- return new SocketReader ($ this -> getReadLength (), $ this -> getReadFlag () );
62+ return new SocketReader ();
16363 }
16464
16565 /**
0 commit comments