File tree Expand file tree Collapse file tree 3 files changed +30
-5
lines changed Expand file tree Collapse file tree 3 files changed +30
-5
lines changed Original file line number Diff line number Diff line change 14
14
15
15
namespace Graze \TelnetClient ;
16
16
17
- class PromptMatcher
17
+ class PromptMatcher implements PromptMatcherInterface
18
18
{
19
19
/**
20
20
* @var array
@@ -33,7 +33,7 @@ class PromptMatcher
33
33
*
34
34
* @return bool
35
35
*/
36
- public function isMatch ($ prompt , $ subject , $ lineEnding )
36
+ public function isMatch ($ prompt , $ subject , $ lineEnding = null )
37
37
{
38
38
// cheap line ending check before expensive regex
39
39
if (substr ($ subject , -1 * strlen ($ lineEnding )) != $ lineEnding ) {
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Graze \TelnetClient ;
4
+
5
+ interface PromptMatcherInterface
6
+ {
7
+ /**
8
+ * @param string $prompt
9
+ * @param string $subject
10
+ * @param string $lineEnding
11
+ * @return bool
12
+ */
13
+ public function isMatch ($ prompt , $ subject , $ lineEnding = null );
14
+
15
+ /**
16
+ * @return string[]
17
+ */
18
+ public function getMatches ();
19
+
20
+ /**
21
+ * @return string
22
+ */
23
+ public function getResponseText ();
24
+ }
Original file line number Diff line number Diff line change 16
16
17
17
use \Graze \TelnetClient \TelnetClientInterface ;
18
18
use \Graze \TelnetClient \PromptMatcher ;
19
+ use \Graze \TelnetClient \PromptMatcherInterface ;
19
20
use \Graze \TelnetClient \InterpretAsCommand ;
20
21
use \Socket \Raw \Socket ;
21
22
use \Socket \Raw \Factory as SocketFactory ;
@@ -31,7 +32,7 @@ class TelnetClient implements TelnetClientInterface
31
32
protected $ socketFactory ;
32
33
33
34
/**
34
- * @var PromptMatcher
35
+ * @var PromptMatcherInterface
35
36
*/
36
37
protected $ promptMatcher ;
37
38
@@ -82,12 +83,12 @@ class TelnetClient implements TelnetClientInterface
82
83
83
84
/**
84
85
* @param SocketFactory $socketFactory
85
- * @param PromptMatcher $promptMatcher
86
+ * @param PromptMatcherInterface $promptMatcher
86
87
* @param InterpretAsCommand $interpretAsCommand
87
88
*/
88
89
public function __construct (
89
90
SocketFactory $ socketFactory ,
90
- PromptMatcher $ promptMatcher ,
91
+ PromptMatcherInterface $ promptMatcher ,
91
92
InterpretAsCommand $ interpretAsCommand
92
93
) {
93
94
$ this ->socketFactory = $ socketFactory ;
You can’t perform that action at this time.
0 commit comments