-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Introduce
StoryRequest
object (#9)
- Loading branch information
1 parent
9098c90
commit a19804b
Showing
5 changed files
with
178 additions
and
40 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,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of Storyblok-Api. | ||
* | ||
* (c) SensioLabs Deutschland <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Storyblok\Api\Request; | ||
|
||
use Storyblok\Api\Domain\Value\Dto\Version; | ||
use Webmozart\Assert\Assert; | ||
|
||
/** | ||
* @author Silas Joisten <[email protected]> | ||
*/ | ||
final readonly class StoryRequest | ||
{ | ||
public function __construct( | ||
public string $language = 'default', | ||
public ?Version $version = null, | ||
) { | ||
Assert::stringNotEmpty($language); | ||
} | ||
|
||
/** | ||
* @return array{ | ||
* language: string, | ||
* version?: string, | ||
* } | ||
*/ | ||
public function toArray(): array | ||
{ | ||
$array = [ | ||
'language' => $this->language, | ||
]; | ||
|
||
if (null !== $this->version) { | ||
$array['version'] = $this->version->value; | ||
} | ||
|
||
return $array; | ||
} | ||
} |
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.