-
-
Notifications
You must be signed in to change notification settings - Fork 177
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 #212 from janvernieuwe/issue/210
Add ImmutableSetterAssemblerOptions + Make all option objects optional
- Loading branch information
Showing
12 changed files
with
158 additions
and
27 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
spec/Phpro/SoapClient/CodeGenerator/Assembler/ImmutableSetterAssemblerOptionsSpec.php
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,35 @@ | ||
<?php | ||
|
||
namespace spec\Phpro\SoapClient\CodeGenerator\Assembler; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
use Phpro\SoapClient\CodeGenerator\Assembler\ImmutableSetterAssemblerOptions; | ||
|
||
/** | ||
* Class ImmutableSetterAssemblerOptionsSpec | ||
*/ | ||
class ImmutableSetterAssemblerOptionsSpec extends ObjectBehavior | ||
{ | ||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(ImmutableSetterAssemblerOptions::class); | ||
} | ||
|
||
function it_should_create_options() | ||
{ | ||
$this::create()->shouldBeAnInstanceOf(ImmutableSetterAssemblerOptions::class); | ||
} | ||
|
||
function it_should_have_false_as_default() | ||
{ | ||
$options = $this::create(); | ||
$options->useTypeHints()->shouldBe(false); | ||
} | ||
|
||
function it_should_set_type_hints() | ||
{ | ||
$options = $this::create()->withTypeHints(); | ||
$options->useTypeHints()->shouldBe(true); | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
src/Phpro/SoapClient/CodeGenerator/Assembler/ImmutableSetterAssemblerOptions.php
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,42 @@ | ||
<?php | ||
|
||
namespace Phpro\SoapClient\CodeGenerator\Assembler; | ||
|
||
/** | ||
* Class ImmutableSetterAssemblerOptions | ||
* @package Phpro\SoapClient\CodeGenerator\Assembler | ||
*/ | ||
class ImmutableSetterAssemblerOptions | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
private $typeHints = false; | ||
|
||
/** | ||
* @return ImmutableSetterAssemblerOptions | ||
*/ | ||
public function withTypeHints(): ImmutableSetterAssemblerOptions | ||
{ | ||
$new = clone $this; | ||
$new->typeHints = true; | ||
|
||
return $new; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function useTypeHints(): bool | ||
{ | ||
return $this->typeHints; | ||
} | ||
|
||
/** | ||
* @return ImmutableSetterAssemblerOptions | ||
*/ | ||
public static function create(): ImmutableSetterAssemblerOptions | ||
{ | ||
return new self(); | ||
} | ||
} |
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
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