Skip to content

Commit

Permalink
Доработаны тест Twig-а
Browse files Browse the repository at this point in the history
  • Loading branch information
npub committed Nov 3, 2021
1 parent 21d2522 commit ed6df15
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Docs language](https://img.shields.io/badge/docs-RU-D52B1E.svg)](https://packagist.org/packages/npub/gos)
[![License](https://poser.pugx.org/npub/gos/license)](https://packagist.org/packages/npub/gos)

Библиотека содержит класс [Snils](https://github.com/npub/gos/blob/main/src/Snils.php) для хранения, проверки и форматирования СНИЛСа, а также Doctrine Type и Trait для использования в качестве свойства Entity. Может использоваться как в составе Symfony проекта с Doctrine ORM, так и независимо.
Библиотека содержит класс [Snils](https://github.com/npub/gos/blob/main/src/Snils.php) для хранения, проверки и форматирования СНИЛСа, а также Doctrine Type, Trait для использования в качестве свойств Entity и расширения Twig. Может использоваться как в составе Symfony проекта с Doctrine ORM, так и независимо.

## Установка
```bash
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "npub/gos",
"type": "library",
"description": "SNILS validation and formatting class for PHP.",
"keywords": ["СНИЛС", "SNILS", "PHP", "Doctrine", "Symfony", "Twig", "Doctrine DBAL", "Doctrine ORM", "Entity", "EntityType"],
"keywords": ["СНИЛС", "SNILS", "PHP", "Doctrine", "Symfony", "Twig", "Doctrine DBAL", "Doctrine ORM", "Entity", "Entity Type"],
"homepage": "https://github.com/npub/gos",
"license": "MIT",
"authors": [
Expand Down
8 changes: 6 additions & 2 deletions src/Snils.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,14 @@ public function isValid(): bool
/**
* Является ли параметр СНИЛСом
*
* @param self|string|int|null $snils Проверяемый СНИЛС
* @param mixed $snils Проверяемый СНИЛС
*/
public static function isSnils(self|string|int|null $snils): bool
public static function isSnils(mixed $snils): bool
{
if (! ($snils instanceof self || is_string($snils) || is_int($snils) || $snils === null)) {
return false;
}

return (bool) self::validate($snils);
}

Expand Down
10 changes: 10 additions & 0 deletions tests/Twig/Fixtures/tests/snils.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
{{ '' is snils ? 'true' : 'false' }}
{{ 123 is snils ? 'true' : 'false' }}
{{ '123' is snils ? 'true' : 'false' }}
{{ [] is snils ? 'true' : 'false' }}
{{ '' is snils ? 'true' : 'false' }}
{{ '-' is snils ? 'true' : 'false' }}
{{ false is snils ? 'true' : 'false' }}
{{ 'not' is snils ? 'true' : 'false' }}
--DATA--
return ['snils_object' => new \Npub\Gos\Snils(123456789)];
--EXPECT--
Expand All @@ -24,3 +29,8 @@ false
false
false
false
false
false
false
false
false

0 comments on commit ed6df15

Please sign in to comment.