Skip to content

Commit

Permalink
1. refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
scarwu committed Jun 5, 2022
1 parent 0e72adf commit d368ec6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion example/CLI/tasks/ReadTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ class ReadTask extends Task
public function run()
{
$this->io->writeln("What is your gender?");

$gender = $this->io->menuSelect([
'male',
'female'
'female',
'other'
]);

// $this->io->write("What is your name? ");
Expand Down
2 changes: 1 addition & 1 deletion src/Oni/CLI/IO.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function __construct()
if (true === (bool) preg_match($optionRegexRule, $value, $match)) {
$this->_options[$match[1]] = null;

if (isset($argv[0])) {
if (true === isset($argv[0])) {
if (true === (bool) preg_match($configRegexRule, $argv[0])) {
continue;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Oni/Web/Http/Req.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private function __construct() {}
*/
public function method(): string
{
$method = isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])
$method = (true === isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']))
? $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']
: $_SERVER['REQUEST_METHOD'];

Expand All @@ -57,7 +57,7 @@ public function method(): string
*/
public function contentLength(): int
{
return isset($_SERVER['CONTENT_LENGTH']) && '' !== $_SERVER['CONTENT_LENGTH']
return (true === isset($_SERVER['CONTENT_LENGTH']) && '' !== $_SERVER['CONTENT_LENGTH'])
? (int) $_SERVER['CONTENT_LENGTH'] : 0;
}

Expand All @@ -74,7 +74,7 @@ public function contentType(): ?string
// * multipart/form-data; boundary=----WebKitFormBoundaryKw2qnJFfEWBNPPYK
// * application/x-www-form-urlencoded
// * application/json
return isset($_SERVER['CONTENT_TYPE']) && '' !== $_SERVER['CONTENT_TYPE']
return (true === isset($_SERVER['CONTENT_TYPE']) && '' !== $_SERVER['CONTENT_TYPE'])
? explode(';', $_SERVER['CONTENT_TYPE'])[0] : null;
}

Expand Down Expand Up @@ -185,7 +185,7 @@ public function file(): array
*/
public function isAjax(): string
{
return isset($_SERVER['HTTP_X_REQUESTED_WITH'])
return (true === isset($_SERVER['HTTP_X_REQUESTED_WITH']))
&& 'XMLHttpRequest' === $_SERVER['HTTP_X_REQUESTED_WITH'];
}
}
2 changes: 1 addition & 1 deletion src/Oni/Web/Http/Res.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function json(array $data, ?integer $option = null): void
{
header('Content-Type: application/json');

echo true === isset($option)
echo (true === isset($option))
? json_encode($data, $option)
: json_encode($data);
}
Expand Down

0 comments on commit d368ec6

Please sign in to comment.