-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add an new simple interactive shell componnent
- Loading branch information
Showing
12 changed files
with
453 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Inhere\Console\Component\Interact; | ||
|
||
use Inhere\Console\Component\InteractiveHandle; | ||
use Toolkit\Stdlib\Str\StrObject; | ||
|
||
/** | ||
* Class AbstractQuestion | ||
* | ||
* @package Inhere\Console\Component\Interact | ||
*/ | ||
abstract class AbstractQuestion extends InteractiveHandle | ||
{ | ||
/** | ||
* @var StrObject | ||
*/ | ||
protected $answer; | ||
|
||
/** | ||
* @param string $str | ||
*/ | ||
protected function createAnswer(string $str): void | ||
{ | ||
$this->answer = StrObject::new($str)->trim(); | ||
} | ||
|
||
/** | ||
* @return StrObject | ||
*/ | ||
public function getAnswer(): StrObject | ||
{ | ||
return $this->answer; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getInt(): int | ||
{ | ||
return $this->answer->toInt(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.