Skip to content

Commit

Permalink
refactor(HasOptions): change access modifiers of methods
Browse files Browse the repository at this point in the history
- Change the access modifiers of getHydratedEscapedNormalizedOptions, getEscapedNormalizedOptions, and getNormalizedOptions methods from public to protected.
  • Loading branch information
guanguans committed Jul 15, 2023
1 parent ec38dfe commit dd0b02e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/Concerns/HasOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1502,23 +1502,23 @@ public function getOption(string $key, $default = null)
/**
* @throws InvalidOptionException
*/
public function getHydratedEscapedNormalizedOptions(): string
protected function getHydratedEscapedNormalizedOptions(): string
{
return implode(' ', $this->getEscapedNormalizedOptions());
}

/**
* @throws InvalidOptionException
*/
public function getEscapedNormalizedOptions(): array
protected function getEscapedNormalizedOptions(): array
{
return array_map('escape_argument', $this->getNormalizedOptions());
}

/**
* @throws InvalidOptionException
*/
public function getNormalizedOptions(): array
protected function getNormalizedOptions(): array
{
return $this->normalizeOptions($this->options);
}
Expand Down
3 changes: 3 additions & 0 deletions src/Concerns/WithRunable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Guanguans\SoarPHP\Concerns;

use Guanguans\SoarPHP\Exceptions\InvalidArgumentException;
use Guanguans\SoarPHP\Exceptions\InvalidOptionException;
use Guanguans\SoarPHP\Exceptions\ProcessFailedException;
use Symfony\Component\Process\Process;

Expand Down Expand Up @@ -52,6 +53,8 @@ protected function exec($withOptions = [], ?callable $processTapper = null, ?cal

/**
* @param array|string $withOptions
*
* @throws InvalidOptionException
*/
private function createProcess($withOptions = [], ?callable $processTapper = null): Process
{
Expand Down
2 changes: 0 additions & 2 deletions tests/Concerns/ConcreteMagicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function testSleep(): void
$this->assertInstanceOf(Soar::class, $unserializedSoar);
$this->assertNotEmpty($unserializedSoar->getSoarPath());
$this->assertNotEmpty($unserializedSoar->getOptions());
$this->assertNotEmpty($unserializedSoar->getNormalizedOptions());
}

/**
Expand All @@ -47,6 +46,5 @@ public function testSetState(): void
$this->assertInstanceOf(Soar::class, $exportedSoar);
$this->assertNotEmpty($exportedSoar->getSoarPath());
$this->assertNotEmpty($exportedSoar->getOptions());
$this->assertNotEmpty($exportedSoar->getNormalizedOptions());
}
}
24 changes: 8 additions & 16 deletions tests/Concerns/HasOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,6 @@ public function testMergeOption(): void
$this->assertSame($val, $option);
}

public function testGetNormalizedOptions(): void
{
$soar = Soar::create();

$this->assertIsArray($soar->getNormalizedOptions());
}

public function testGetHydratedEscapedNormalizedOptions(): void
{
$soar = Soar::create();

$this->assertIsString($soar->getHydratedEscapedNormalizedOptions());
}

public function testGetOptions(): void
{
$soar = Soar::create();
Expand Down Expand Up @@ -151,7 +137,9 @@ public function testInvalidOptionExceptionForNormalizeOptions(): void
{
$this->expectException(InvalidOptionException::class);
$this->expectExceptionMessage('object');
Soar::create(['foo' => $this->createMock(\stdClass::class)])->getNormalizedOptions();
(function () {
return $this->getNormalizedOptions();
})->call(Soar::create(['foo' => $this->createMock(\stdClass::class)]));
}

public function testNormalizeOptions(): void
Expand Down Expand Up @@ -183,6 +171,10 @@ public function testNormalizeOptions(): void
'invoke' => new InvokeOption(),
]);

$this->assertIsArray($soar->getNormalizedOptions());
$this->assertIsArray(
(function () {
return $this->getNormalizedOptions();
})->call($soar)
);
}
}

0 comments on commit dd0b02e

Please sign in to comment.