File tree Expand file tree Collapse file tree 5 files changed +108
-0
lines changed Expand file tree Collapse file tree 5 files changed +108
-0
lines changed Original file line number Diff line number Diff line change
1
+ /vendor /
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " rubyqorn/web-socket" ,
3
+ "description" : " Socket layer over PHP socket api" ,
4
+ "type" : " library" ,
5
+ "license" : " MIT" ,
6
+ "authors" : [
7
+ {
8
+ "name" : " Anton Hideger" ,
9
+ "email" : " rubyqorn@example.com"
10
+ }
11
+ ],
12
+ "autoload" : {
13
+ "psr-4" : {
14
+ "WebSocket\\ " : " src/"
15
+ }
16
+ },
17
+ "require" : {}
18
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace WebSocket ;
4
+
5
+ class Socket
6
+ {
7
+ protected ?ICredential $ credential ;
8
+
9
+ /**
10
+ * DI of SocketCredentials
11
+ * @param ICredential $credential
12
+ * @return void
13
+ */
14
+ public function setCredentials (ICredential $ credential )
15
+ {
16
+ $ this ->credential = $ credential ;
17
+ }
18
+
19
+ /**
20
+ * Return instance of SocketCredentials
21
+ * @return SocketCredentials
22
+ */
23
+ public function getCredentials ()
24
+ {
25
+ return $ this ->credential ;
26
+ }
27
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace WebSocket \Credential ;
4
+
5
+ interface ICredential
6
+ {
7
+ /**
8
+ * Set value for specified property name
9
+ * @param string $name
10
+ * @param string $value
11
+ * @return void
12
+ */
13
+ public function setCredential (string $ name , string $ value );
14
+
15
+ /**
16
+ * Get value of property by specified property
17
+ * name
18
+ * @param string $name
19
+ * @return mixed
20
+ */
21
+ public function getCredential (string $ name );
22
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace WebSocket \Credential ;
4
+
5
+ class SocketCredentials implements ICredential
6
+ {
7
+ /**
8
+ * Host name where will
9
+ * be connected
10
+ * @var string
11
+ */
12
+ private string $ host ;
13
+
14
+ /**
15
+ * Port for host
16
+ * @var string
17
+ */
18
+ private string $ port ;
19
+
20
+ /**
21
+ * Set credentials for socket connection
22
+ * @param string $name
23
+ * @param string $value
24
+ * @return void
25
+ */
26
+ public function setCredential (string $ name , string $ value )
27
+ {
28
+ $ this ->$ name = $ value ;
29
+ }
30
+
31
+ /**
32
+ * Get credentials for socket connection
33
+ * @param string $name
34
+ * @return string
35
+ */
36
+ public function getCredential (string $ name )
37
+ {
38
+ return $ this ->$ name ;
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments