-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ced4dc
commit f53f545
Showing
5 changed files
with
169 additions
and
26 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
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,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RetailCrm\Api\Component\Serializer\Parser\JMSCore\Type; | ||
|
||
use function in_array; | ||
|
||
/** | ||
* @template T of string|int | ||
* @template V of string|int | ||
*/ | ||
final class Token | ||
{ | ||
public static function fromArray(array $source): Token | ||
Check failure on line 15 in src/Component/Serializer/Parser/JMSCore/Type/Token.php GitHub Actions / PHPStan
|
||
{ | ||
return new self($source['value'] ?? '', $source['type'] ?? '', $source['position'] ?? ''); | ||
} | ||
|
||
public static function fromObject(object $source): Token | ||
{ | ||
return new self($source->value, $source->type, $source->position); | ||
} | ||
|
||
/** | ||
* The string value of the token in the input string | ||
* | ||
* @readonly | ||
* @var string|int | ||
*/ | ||
public $value; | ||
|
||
/** | ||
* The type of the token (identifier, numeric, string, input parameter, none) | ||
* | ||
* @readonly | ||
* @var T|null | ||
*/ | ||
public $type; | ||
|
||
/** | ||
* The position of the token in the input string | ||
* | ||
* @readonly | ||
*/ | ||
public int $position; | ||
|
||
/** | ||
* @param string|int $value | ||
* @param string|int $type | ||
*/ | ||
public function __construct($value, $type, int $position) | ||
{ | ||
$this->value = $value; | ||
$this->type = $type; | ||
$this->position = $position; | ||
} | ||
|
||
/** @param T ...$types */ | ||
public function isA(...$types): bool | ||
{ | ||
return in_array($this->type, $types, 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