-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from phpsu/task/add-shell-word
add shell word
- Loading branch information
Showing
17 changed files
with
736 additions
and
127 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 was deleted.
Oops, something went wrong.
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
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,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPSu\ShellCommandBuilder\Literal; | ||
|
||
use PHPSu\ShellCommandBuilder\Exception\ShellBuilderException; | ||
use PHPSu\ShellCommandBuilder\ShellInterface; | ||
|
||
final class ShellArgument extends ShellWord | ||
{ | ||
protected $isArgument = true; | ||
protected $delimiter = ''; | ||
|
||
/** | ||
* ShellArgument constructor. | ||
* @param ShellInterface|string $argument | ||
*/ | ||
public function __construct($argument) | ||
{ | ||
parent::__construct('', $argument); | ||
} | ||
|
||
protected function validate(): void | ||
{ | ||
if (is_string($this->value) && empty($this->value)) { | ||
throw new ShellBuilderException('Argument cant be empty'); | ||
} | ||
parent::validate(); | ||
} | ||
} |
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,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPSu\ShellCommandBuilder\Literal; | ||
|
||
use PHPSu\ShellCommandBuilder\ShellInterface; | ||
|
||
final class ShellEnvironmentVariable extends ShellWord | ||
{ | ||
protected $isEnvironmentVariable = true; | ||
protected $useAssignOperator = true; | ||
protected $nameUpperCase = true; | ||
|
||
/** | ||
* ShellArgument constructor. | ||
* @param string $option | ||
* @param ShellInterface|string $value | ||
*/ | ||
public function __construct(string $option, $value) | ||
{ | ||
parent::__construct($option, $value); | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPSu\ShellCommandBuilder\Literal; | ||
|
||
final class ShellExecutable extends ShellWord | ||
{ | ||
protected $isArgument = true; | ||
protected $spaceAfterValue = false; | ||
protected $isEscaped = false; | ||
protected $delimiter = ''; | ||
protected $prefix = ''; | ||
protected $suffix = ''; | ||
|
||
public function __construct(string $executable) | ||
{ | ||
parent::__construct($executable); | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPSu\ShellCommandBuilder\Literal; | ||
|
||
use PHPSu\ShellCommandBuilder\ShellInterface; | ||
|
||
final class ShellOption extends ShellWord | ||
{ | ||
protected $isOption = true; | ||
protected $prefix = ShellWord::OPTION_CONTROL; | ||
|
||
/** | ||
* ShellArgument constructor. | ||
* @param string $option | ||
* @param ShellInterface|string $value | ||
*/ | ||
public function __construct(string $option, $value = '') | ||
{ | ||
if (is_string($value) && empty($value)) { | ||
$this->delimiter = ''; | ||
} | ||
parent::__construct($option, $value); | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPSu\ShellCommandBuilder\Literal; | ||
|
||
use PHPSu\ShellCommandBuilder\ShellInterface; | ||
|
||
final class ShellShortOption extends ShellWord | ||
{ | ||
protected $isShortOption = true; | ||
protected $prefix = ShellWord::SHORT_OPTION_CONTROL; | ||
|
||
/** | ||
* ShellArgument constructor. | ||
* @param string $option | ||
* @param ShellInterface|string $value | ||
*/ | ||
public function __construct(string $option, $value) | ||
{ | ||
if (is_string($value) && empty($value)) { | ||
$this->delimiter = ''; | ||
} | ||
parent::__construct($option, $value); | ||
} | ||
} |
Oops, something went wrong.