Skip to content

Commit ee5e0ec

Browse files
committed
add some io interface classs
1 parent 222af93 commit ee5e0ec

File tree

4 files changed

+81
-1
lines changed

4 files changed

+81
-1
lines changed

src/Contract/IOInterface.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php declare(strict_types=1);
2+
3+
4+
namespace Toolkit\Extlib\Contract;
5+
6+
/**
7+
* Interface IOInterface
8+
* @package Toolkit\Extlib\Contract
9+
*/
10+
interface IOInterface extends InputInterface, OutputInterface
11+
{
12+
13+
}

src/Contract/InputInterface.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Toolkit\Extlib\Contract;
4+
5+
/**
6+
* Interface InputInterface
7+
* @package Toolkit\Extlib\Contract
8+
*/
9+
interface InputInterface
10+
{
11+
/**
12+
* @param int $length
13+
*
14+
* @return string
15+
*/
16+
public function read(int $length): string;
17+
18+
/**
19+
* @return string
20+
*/
21+
public function readln(): string;
22+
23+
/**
24+
* @return string
25+
*/
26+
public function readAll(): string;
27+
28+
/**
29+
* Whether the stream is an interactive terminal
30+
*/
31+
public function isInteractive() : bool;
32+
}

src/Contract/OutputInterface.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php declare(strict_types=1);
2+
3+
4+
namespace Toolkit\Extlib\Contract;
5+
6+
/**
7+
* Class OutputInterface
8+
*
9+
* @package Toolkit\Extlib\Contract
10+
*/
11+
interface OutputInterface
12+
{
13+
/**
14+
* Write a message to output
15+
*
16+
* @param string $content
17+
*
18+
* @return int
19+
*/
20+
public function write(string $content): int;
21+
22+
/**
23+
* Write a message to output with newline
24+
*
25+
* @param string $content
26+
*
27+
* @return int
28+
*/
29+
public function writeln(string $content): int;
30+
31+
/**
32+
* Whether the stream is an interactive terminal
33+
*/
34+
public function isInteractive() : bool;
35+
}

src/IO/StreamIO.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
class StreamIO
1111
{
1212

13-
}
13+
}

0 commit comments

Comments
 (0)