-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
14 changed files
with
283 additions
and
93 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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Liquetsoft\Fias\Component\Helper; | ||
|
||
/** | ||
* Класс, который содержит функции для генерации уникальных идентификаторов. | ||
*/ | ||
final class IdHelper | ||
{ | ||
private const RANDOM_BYTE_SIZE = 30; | ||
|
||
private function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* Создает строку, содержащую уникальны идентификатор. | ||
*/ | ||
public static function createUniqueId(): string | ||
{ | ||
return md5(time() . random_bytes(self::RANDOM_BYTE_SIZE)); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Liquetsoft\Fias\Component\Serializer; | ||
|
||
/** | ||
* Список параметров контекста, которые поддерживает сериализатор. | ||
*/ | ||
enum FiasSerializerContextParam: string | ||
{ | ||
case FIAS_FLAG = 'is_fias'; | ||
case FIAS_ENTITY = 'fias_entity'; | ||
} |
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,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Liquetsoft\Fias\Component\Serializer; | ||
|
||
/** | ||
* Список форматов, которые поддерживает сериализатор. | ||
*/ | ||
enum FiasSerializerFormat: string | ||
{ | ||
case XML = 'xml'; | ||
case TEST = 'test'; | ||
|
||
/** | ||
* Проверяет, что указанная строка совпадает с текущим форматом. | ||
*/ | ||
public function isEqual(mixed $format): bool | ||
{ | ||
return \is_string($format) && strtolower(trim($format)) === $this->value; | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Liquetsoft\Fias\Component\Tests\Helper; | ||
|
||
use Liquetsoft\Fias\Component\Helper\IdHelper; | ||
use Liquetsoft\Fias\Component\Tests\BaseCase; | ||
|
||
/** | ||
* Тест для класса, который содержит методы для генерации уникальных идентификаторов. | ||
* | ||
* @internal | ||
*/ | ||
class IdHelperTest extends BaseCase | ||
{ | ||
/** | ||
* Проверяет, что метод вернет уникальный идентификатор. | ||
*/ | ||
public function testCreateUniqueId(): void | ||
{ | ||
$id = IdHelper::createUniqueId(); | ||
|
||
$this->assertSame(32, \strlen($id)); | ||
} | ||
} |
Oops, something went wrong.