File tree Expand file tree Collapse file tree 4 files changed +40
-43
lines changed
src/Jumper/Communicator/Authentication Expand file tree Collapse file tree 4 files changed +40
-43
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+
4+ namespace Jumper \Communicator \Authentication ;
5+
6+ /**
7+ * Class AbstractAuthentication
8+ *
9+ * @package Jumper\Communicator\Authentication
10+ * @author Thibaud Leprêtre
11+ * @license MIT
12+ */
13+ abstract class AbstractAuthentication
14+ {
15+ protected $ user ;
16+
17+ public function __construct ($ user )
18+ {
19+ $ this ->user = $ user ;
20+ }
21+
22+ public function getUser ()
23+ {
24+ return $ this ->user ;
25+ }
26+ }
Original file line number Diff line number Diff line change 1111 * @author Thibaud Leprêtre
1212 * @license MIT
1313 */
14- class None implements Authentication
14+ class None extends AbstractAuthentication implements Authentication
1515{
16+
1617 /**
17- * @var string user
18+ * @param string $ user
1819 */
19- private $ user ;
20-
2120 public function __construct ($ user )
2221 {
23- $ this -> user = $ user ;
22+ parent :: __construct ( $ user) ;
2423 }
2524
2625 /**
@@ -31,11 +30,4 @@ public function getAuthentication()
3130 return null ;
3231 }
3332
34- /**
35- * @return string user
36- */
37- public function getUser ()
38- {
39- return $ this ->user ;
40- }
4133}
Original file line number Diff line number Diff line change 1111 * @author Thibaud Leprêtre
1212 * @license MIT
1313 */
14- class Password implements Authentication
14+ class Password extends AbstractAuthentication implements Authentication
1515{
1616
17- /**
18- * @var string user
19- */
20- private $ user ;
21-
2217 /**
2318 * @var string password
2419 */
2520 private $ password ;
2621
2722 /**
2823 * @param string $user
29- * @param $password
24+ * @param string $password
3025 */
31- public function _construct ($ user , $ password )
26+ public function __construct ($ user , $ password )
3227 {
33- $ this -> user = $ user ;
28+ parent :: __construct ( $ user) ;
3429 $ this ->password = $ password ;
3530 }
3631
3732 /**
38- * @return mixed
33+ * @return string
3934 */
4035 public function getAuthentication ()
4136 {
4237 return $ this ->password ;
4338 }
4439
45- /**
46- * @return mixed
47- */
48- public function getUser ()
49- {
50- return $ this ->user ;
51- }
5240}
Original file line number Diff line number Diff line change 1212 * @author Thibaud Leprêtre
1313 * @license MIT
1414 */
15- class Rsa implements Authentication
15+ class Rsa extends AbstractAuthentication implements Authentication
1616{
1717
18- /**
19- * @var string user
20- */
21- private $ user ;
22-
2318 /**
2419 * @var string rsa key path
2520 */
@@ -37,7 +32,7 @@ class Rsa implements Authentication
3732 */
3833 public function __construct ($ user , $ key , $ password = null )
3934 {
40- $ this -> user = $ user ;
35+ parent :: __construct ( $ user) ;
4136 $ this ->key = $ key ;
4237 $ this ->password = $ password ;
4338 }
@@ -49,14 +44,10 @@ public function getAuthentication()
4944 {
5045 $ key = new RsaKey ();
5146 $ key ->loadKey (file_get_contents ($ this ->key ));
47+ if (!isNull ($ this ->password )) {
48+ $ key ->setPassword ($ this ->password );
49+ }
5250 return $ key ;
5351 }
5452
55- /**
56- * @return string user
57- */
58- public function getUser ()
59- {
60- return $ this ->user ;
61- }
6253}
You can’t perform that action at this time.
0 commit comments