Enhance refactor commands with controller-aware Route() updates and fix code quality violations
Add semantic token highlighting for 'that' variable and comment file references in VS Code extension Add Phone_Text_Input and Currency_Input components with formatting utilities Implement client widgets, form standardization, and soft delete functionality Add modal scroll lock and update documentation Implement comprehensive modal system with form integration and validation Fix modal component instantiation using jQuery plugin API Implement modal system with responsive sizing, queuing, and validation support Implement form submission with validation, error handling, and loading states Implement country/state selectors with dynamic data loading and Bootstrap styling Revert Rsx::Route() highlighting in Blade/PHP files Target specific PHP scopes for Rsx::Route() highlighting in Blade Expand injection selector for Rsx::Route() highlighting Add custom syntax highlighting for Rsx::Route() and Rsx.Route() calls Update jqhtml packages to v2.2.165 Add bundle path validation for common mistakes (development mode only) Create Ajax_Select_Input widget and Rsx_Reference_Data controller Create Country_Select_Input widget with default country support Initialize Tom Select on Select_Input widgets Add Tom Select bundle for enhanced select dropdowns Implement ISO 3166 geographic data system for country/region selection Implement widget-based form system with disabled state support 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
82
vendor/sokil/php-isocodes/src/Database/Countries.php
vendored
Normal file
82
vendor/sokil/php-isocodes/src/Database/Countries.php
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database;
|
||||
|
||||
use Sokil\IsoCodes\AbstractNotPartitionedDatabase;
|
||||
use Sokil\IsoCodes\Database\Countries\Country;
|
||||
|
||||
/**
|
||||
* @method Country|null find(string $indexedFieldName, string $fieldValue)
|
||||
*/
|
||||
class Countries extends AbstractNotPartitionedDatabase
|
||||
{
|
||||
/**
|
||||
* ISO Standard Number
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public static function getISONumber(): string
|
||||
{
|
||||
return '3166-1';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $entry
|
||||
*/
|
||||
protected function arrayToEntry(array $entry): Country
|
||||
{
|
||||
return new Country(
|
||||
$this->translationDriver,
|
||||
$entry['name'],
|
||||
$entry['alpha_2'],
|
||||
$entry['alpha_3'],
|
||||
$entry['numeric'],
|
||||
$entry['flag'],
|
||||
!empty($entry['official_name']) ? $entry['official_name'] : null,
|
||||
!empty($entry['common_name']) ? $entry['common_name'] : null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getIndexDefinition(): array
|
||||
{
|
||||
return [
|
||||
'alpha_2',
|
||||
'alpha_3',
|
||||
'numeric'
|
||||
];
|
||||
}
|
||||
|
||||
public function getByAlpha2(string $alpha2): ?Country
|
||||
{
|
||||
return $this->find('alpha_2', $alpha2);
|
||||
}
|
||||
|
||||
public function getByAlpha3(string $alpha3): ?Country
|
||||
{
|
||||
return $this->find('alpha_3', $alpha3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Using int code argument is deprecated due to it can be with leading 0 (e.g. '042').
|
||||
* Please, use numeric strings.
|
||||
*
|
||||
* @param string|int $code
|
||||
*
|
||||
* @return Country|null
|
||||
*
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public function getByNumericCode($code): ?Country
|
||||
{
|
||||
if (!is_numeric($code)) {
|
||||
throw new \TypeError('Argument must be int or string');
|
||||
}
|
||||
|
||||
return $this->find('numeric', (string)$code);
|
||||
}
|
||||
}
|
||||
128
vendor/sokil/php-isocodes/src/Database/Countries/Country.php
vendored
Normal file
128
vendor/sokil/php-isocodes/src/Database/Countries/Country.php
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database\Countries;
|
||||
|
||||
use Sokil\IsoCodes\Database\Countries;
|
||||
use Sokil\IsoCodes\TranslationDriver\TranslatorInterface;
|
||||
|
||||
class Country
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $localName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $alpha2;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $alpha3;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $numericCode;
|
||||
|
||||
/**
|
||||
* Emoji of country flag
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $flag;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $officialName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $commonName;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
private $translator;
|
||||
|
||||
public function __construct(
|
||||
TranslatorInterface $translator,
|
||||
string $name,
|
||||
string $alpha2,
|
||||
string $alpha3,
|
||||
string $numericCode,
|
||||
string $flag,
|
||||
?string $officialName = null,
|
||||
?string $commonName = null
|
||||
) {
|
||||
$this->translator = $translator;
|
||||
$this->name = $name;
|
||||
$this->alpha2 = $alpha2;
|
||||
$this->alpha3 = $alpha3;
|
||||
$this->numericCode = $numericCode;
|
||||
$this->flag = $flag;
|
||||
$this->officialName = $officialName;
|
||||
$this->commonName = $commonName;
|
||||
}
|
||||
|
||||
public function getAlpha2(): string
|
||||
{
|
||||
return $this->alpha2;
|
||||
}
|
||||
|
||||
public function getAlpha3(): string
|
||||
{
|
||||
return $this->alpha3;
|
||||
}
|
||||
|
||||
public function getNumericCode(): string
|
||||
{
|
||||
return $this->numericCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFlag(): string
|
||||
{
|
||||
return $this->flag;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getLocalName(): string
|
||||
{
|
||||
if ($this->localName === null) {
|
||||
$this->localName = $this->translator->translate(
|
||||
Countries::getISONumber(),
|
||||
$this->name
|
||||
);
|
||||
}
|
||||
|
||||
return $this->localName;
|
||||
}
|
||||
|
||||
public function getOfficialName(): ?string
|
||||
{
|
||||
return $this->officialName;
|
||||
}
|
||||
|
||||
public function getCommonName(): ?string
|
||||
{
|
||||
return $this->commonName;
|
||||
}
|
||||
}
|
||||
72
vendor/sokil/php-isocodes/src/Database/Currencies.php
vendored
Normal file
72
vendor/sokil/php-isocodes/src/Database/Currencies.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database;
|
||||
|
||||
use Sokil\IsoCodes\AbstractNotPartitionedDatabase;
|
||||
use Sokil\IsoCodes\Database\Currencies\Currency;
|
||||
|
||||
/**
|
||||
* @method Currency|null find(string $indexedFieldName, string $fieldValue)
|
||||
*/
|
||||
class Currencies extends AbstractNotPartitionedDatabase
|
||||
{
|
||||
/**
|
||||
* ISO Standard Number
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public static function getISONumber(): string
|
||||
{
|
||||
return '4217';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $entry
|
||||
*/
|
||||
protected function arrayToEntry(array $entry): Currency
|
||||
{
|
||||
return new Currency(
|
||||
$this->translationDriver,
|
||||
$entry['name'],
|
||||
$entry['alpha_3'],
|
||||
$entry['numeric']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getIndexDefinition(): array
|
||||
{
|
||||
return [
|
||||
'alpha_3',
|
||||
'numeric'
|
||||
];
|
||||
}
|
||||
|
||||
public function getByLetterCode(string $code): ?Currency
|
||||
{
|
||||
return $this->find('alpha_3', $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Using int code argument is deprecated due to it can be with leading 0 (e.g. '042').
|
||||
* Please, use numeric strings.
|
||||
*
|
||||
* @param string|int $code
|
||||
*
|
||||
* @return Currency|null
|
||||
*
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public function getByNumericCode($code): ?Currency
|
||||
{
|
||||
if (!is_numeric($code)) {
|
||||
throw new \TypeError('Argument must be int or string');
|
||||
}
|
||||
|
||||
return $this->find('numeric', (string)$code);
|
||||
}
|
||||
}
|
||||
77
vendor/sokil/php-isocodes/src/Database/Currencies/Currency.php
vendored
Normal file
77
vendor/sokil/php-isocodes/src/Database/Currencies/Currency.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database\Currencies;
|
||||
|
||||
use Sokil\IsoCodes\Database\Currencies;
|
||||
use Sokil\IsoCodes\TranslationDriver\TranslatorInterface;
|
||||
|
||||
class Currency
|
||||
{
|
||||
/**
|
||||
* Alpha3
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $letterCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $numericCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $localName;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
private $translator;
|
||||
|
||||
public function __construct(
|
||||
TranslatorInterface $translator,
|
||||
string $name,
|
||||
string $letterCode,
|
||||
string $numericCode
|
||||
) {
|
||||
$this->translator = $translator;
|
||||
$this->name = $name;
|
||||
$this->letterCode = $letterCode;
|
||||
$this->numericCode = $numericCode;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getLocalName(): string
|
||||
{
|
||||
if ($this->localName === null) {
|
||||
$this->localName = $this->translator->translate(
|
||||
Currencies::getISONumber(),
|
||||
$this->name
|
||||
);
|
||||
}
|
||||
|
||||
return $this->localName;
|
||||
}
|
||||
|
||||
public function getLetterCode(): string
|
||||
{
|
||||
return $this->letterCode;
|
||||
}
|
||||
|
||||
public function getNumericCode(): string
|
||||
{
|
||||
return $this->numericCode;
|
||||
}
|
||||
}
|
||||
87
vendor/sokil/php-isocodes/src/Database/HistoricCountries.php
vendored
Normal file
87
vendor/sokil/php-isocodes/src/Database/HistoricCountries.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database;
|
||||
|
||||
use Sokil\IsoCodes\AbstractNotPartitionedDatabase;
|
||||
use Sokil\IsoCodes\Database\HistoricCountries\Country;
|
||||
|
||||
/**
|
||||
* @method Country|null find(string $indexedFieldName, string $fieldValue)
|
||||
*/
|
||||
class HistoricCountries extends AbstractNotPartitionedDatabase
|
||||
{
|
||||
/**
|
||||
* ISO Standard Number
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public static function getISONumber(): string
|
||||
{
|
||||
return '3166-3';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $entry
|
||||
*/
|
||||
protected function arrayToEntry(array $entry): Country
|
||||
{
|
||||
return new Country(
|
||||
$this->translationDriver,
|
||||
$entry['name'],
|
||||
$entry['alpha_4'],
|
||||
$entry['alpha_3'],
|
||||
$entry['alpha_2'],
|
||||
$entry['withdrawal_date'],
|
||||
!empty($entry['numeric']) ? $entry['numeric'] : null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getIndexDefinition(): array
|
||||
{
|
||||
return [
|
||||
'alpha_4',
|
||||
'alpha_3',
|
||||
'alpha_2',
|
||||
'numeric'
|
||||
];
|
||||
}
|
||||
|
||||
public function getByAlpha4(string $code): ?Country
|
||||
{
|
||||
return $this->find('alpha_4', $code);
|
||||
}
|
||||
|
||||
public function getByAlpha3(string $code): ?Country
|
||||
{
|
||||
return $this->find('alpha_3', $code);
|
||||
}
|
||||
|
||||
public function getByAlpha2(string $code): ?Country
|
||||
{
|
||||
return $this->find('alpha_2', $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Using int code argument is deprecated due to it can be with leading 0 (e.g. '042').
|
||||
* Please, use numeric strings.
|
||||
*
|
||||
* @param string|int $code
|
||||
*
|
||||
* @return Country|null
|
||||
*
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public function getByNumericCode($code): ?Country
|
||||
{
|
||||
if (!is_numeric($code)) {
|
||||
throw new \TypeError('Argument must be int or string');
|
||||
}
|
||||
|
||||
return $this->find('numeric', (string)$code);
|
||||
}
|
||||
}
|
||||
111
vendor/sokil/php-isocodes/src/Database/HistoricCountries/Country.php
vendored
Normal file
111
vendor/sokil/php-isocodes/src/Database/HistoricCountries/Country.php
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database\HistoricCountries;
|
||||
|
||||
use Sokil\IsoCodes\Database\HistoricCountries;
|
||||
use Sokil\IsoCodes\TranslationDriver\TranslatorInterface;
|
||||
|
||||
class Country
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $localName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $alpha4;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $alpha3;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $alpha2;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $withdrawalDate;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
public $numericCode;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
private $translator;
|
||||
|
||||
public function __construct(
|
||||
TranslatorInterface $translator,
|
||||
string $name,
|
||||
string $alpha4,
|
||||
string $alpha3,
|
||||
string $alpha2,
|
||||
string $withdrawalDate,
|
||||
?string $numericCode = null
|
||||
) {
|
||||
$this->translator = $translator;
|
||||
$this->name = $name;
|
||||
$this->alpha4 = $alpha4;
|
||||
$this->alpha3 = $alpha3;
|
||||
$this->alpha2 = $alpha2;
|
||||
$this->withdrawalDate = $withdrawalDate;
|
||||
$this->numericCode = $numericCode;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getLocalName(): string
|
||||
{
|
||||
if ($this->localName === null) {
|
||||
$this->localName = $this->translator->translate(
|
||||
HistoricCountries::getISONumber(),
|
||||
$this->name
|
||||
);
|
||||
}
|
||||
|
||||
return $this->localName;
|
||||
}
|
||||
|
||||
public function getAlpha4(): string
|
||||
{
|
||||
return $this->alpha4;
|
||||
}
|
||||
|
||||
public function getAlpha3(): string
|
||||
{
|
||||
return $this->alpha3;
|
||||
}
|
||||
|
||||
public function getAlpha2(): string
|
||||
{
|
||||
return $this->alpha2;
|
||||
}
|
||||
|
||||
public function getWithdrawalDate(): string
|
||||
{
|
||||
return $this->withdrawalDate;
|
||||
}
|
||||
|
||||
public function getNumericCode(): ?string
|
||||
{
|
||||
return $this->numericCode;
|
||||
}
|
||||
}
|
||||
61
vendor/sokil/php-isocodes/src/Database/Languages.php
vendored
Normal file
61
vendor/sokil/php-isocodes/src/Database/Languages.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database;
|
||||
|
||||
use Sokil\IsoCodes\AbstractNotPartitionedDatabase;
|
||||
use Sokil\IsoCodes\Database\Languages\Language;
|
||||
|
||||
/**
|
||||
* @method Language|null find(string $indexedFieldName, string $fieldValue)
|
||||
*/
|
||||
class Languages extends AbstractNotPartitionedDatabase implements LanguagesInterface
|
||||
{
|
||||
/**
|
||||
* ISO Standard Number
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public static function getISONumber(): string
|
||||
{
|
||||
return '639-3';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $entry
|
||||
*/
|
||||
protected function arrayToEntry(array $entry): Language
|
||||
{
|
||||
return new Language(
|
||||
$this->translationDriver,
|
||||
$entry['name'],
|
||||
$entry['alpha_3'],
|
||||
$entry['scope'],
|
||||
$entry['type'],
|
||||
!empty($entry['inverted_name']) ? $entry['inverted_name'] : null,
|
||||
!empty($entry['alpha_2']) ? $entry['alpha_2'] : null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getIndexDefinition(): array
|
||||
{
|
||||
return [
|
||||
'alpha_2',
|
||||
'alpha_3',
|
||||
];
|
||||
}
|
||||
|
||||
public function getByAlpha2(string $alpha2): ?Language
|
||||
{
|
||||
return $this->find('alpha_2', $alpha2);
|
||||
}
|
||||
|
||||
public function getByAlpha3(string $alpha3): ?Language
|
||||
{
|
||||
return $this->find('alpha_3', $alpha3);
|
||||
}
|
||||
}
|
||||
146
vendor/sokil/php-isocodes/src/Database/Languages/Language.php
vendored
Normal file
146
vendor/sokil/php-isocodes/src/Database/Languages/Language.php
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database\Languages;
|
||||
|
||||
use Sokil\IsoCodes\Database\Languages;
|
||||
use Sokil\IsoCodes\TranslationDriver\TranslatorInterface;
|
||||
|
||||
class Language
|
||||
{
|
||||
/**
|
||||
* @see https://iso639-3.sil.org/about/scope
|
||||
*/
|
||||
public const SCOPE_COLLECTIVE = 'C';
|
||||
public const SCOPE_INDIVIDUAL = 'I';
|
||||
public const SCOPE_LOCAL = 'L';
|
||||
public const SCOPE_MACROLANGUAGE = 'M';
|
||||
public const SCOPE_SPECIAL = 'S';
|
||||
|
||||
/**
|
||||
* @see https://iso639-3.sil.org/about/types
|
||||
*/
|
||||
public const TYPE_ANCIENT = 'A';
|
||||
public const TYPE_CONSTRUCTED = 'C';
|
||||
public const TYPE_EXTINCT = 'E';
|
||||
public const TYPE_GENETIC = 'GENETIC'; // not supported
|
||||
public const TYPE_GENETIC_ANCIENT = 'GENETIC_ANCIENT'; // not supported
|
||||
public const TYPE_GENETIC_LIKE = 'GENETIC_LIKE'; // not supported
|
||||
public const TYPE_GEOGRAPHIC = 'GEOGRAPHIC'; // not supported
|
||||
public const TYPE_HISTORICAL = 'H';
|
||||
public const TYPE_LIVING = 'L';
|
||||
public const TYPE_SPECIAL = 'S';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $localName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $alpha3;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* Scope of denotation
|
||||
*
|
||||
* One of self::SCOPE_*
|
||||
*
|
||||
* @see https://iso639-3.sil.org/about/scope
|
||||
*/
|
||||
private $scope;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* Type of language
|
||||
*
|
||||
* One of TYPE_*
|
||||
*
|
||||
* @see https://iso639-3.sil.org/about/types
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $invertedName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $alpha2;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
private $translator;
|
||||
|
||||
public function __construct(
|
||||
TranslatorInterface $translator,
|
||||
string $name,
|
||||
string $alpha3,
|
||||
string $scope,
|
||||
string $type,
|
||||
?string $invertedName = null,
|
||||
?string $alpha2 = null
|
||||
) {
|
||||
$this->translator = $translator;
|
||||
$this->name = $name;
|
||||
$this->alpha3 = $alpha3;
|
||||
$this->scope = $scope;
|
||||
$this->type = $type;
|
||||
$this->invertedName = $invertedName;
|
||||
$this->alpha2 = $alpha2;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getLocalName(): string
|
||||
{
|
||||
if ($this->localName === null) {
|
||||
$this->localName = $this->translator->translate(
|
||||
Languages::getISONumber(),
|
||||
$this->name
|
||||
);
|
||||
}
|
||||
|
||||
return $this->localName;
|
||||
}
|
||||
|
||||
public function getAlpha3(): string
|
||||
{
|
||||
return $this->alpha3;
|
||||
}
|
||||
|
||||
public function getScope(): string
|
||||
{
|
||||
return $this->scope;
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getInvertedName(): ?string
|
||||
{
|
||||
return $this->invertedName;
|
||||
}
|
||||
|
||||
public function getAlpha2(): ?string
|
||||
{
|
||||
return $this->alpha2;
|
||||
}
|
||||
}
|
||||
14
vendor/sokil/php-isocodes/src/Database/LanguagesInterface.php
vendored
Normal file
14
vendor/sokil/php-isocodes/src/Database/LanguagesInterface.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database;
|
||||
|
||||
use Sokil\IsoCodes\Database\Languages\Language;
|
||||
|
||||
interface LanguagesInterface extends \Iterator, \Countable
|
||||
{
|
||||
public function getByAlpha2(string $alpha2): ?Language;
|
||||
|
||||
public function getByAlpha3(string $alpha3): ?Language;
|
||||
}
|
||||
63
vendor/sokil/php-isocodes/src/Database/LanguagesPartitioned.php
vendored
Normal file
63
vendor/sokil/php-isocodes/src/Database/LanguagesPartitioned.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database;
|
||||
|
||||
use Sokil\IsoCodes\AbstractPartitionedDatabase;
|
||||
use Sokil\IsoCodes\Database\Languages\Language;
|
||||
|
||||
class LanguagesPartitioned extends AbstractPartitionedDatabase implements LanguagesInterface
|
||||
{
|
||||
/**
|
||||
* ISO Standard Number
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public static function getISONumber(): string
|
||||
{
|
||||
return '639-3';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $entry
|
||||
*/
|
||||
protected function arrayToEntry(array $entry): Language
|
||||
{
|
||||
return new Language(
|
||||
$this->translationDriver,
|
||||
$entry['name'],
|
||||
$entry['alpha_3'],
|
||||
$entry['scope'],
|
||||
$entry['type'],
|
||||
!empty($entry['inverted_name']) ? $entry['inverted_name'] : null,
|
||||
!empty($entry['alpha_2']) ? $entry['alpha_2'] : null
|
||||
);
|
||||
}
|
||||
|
||||
public function getByAlpha2(string $alpha2): ?Language
|
||||
{
|
||||
$language = null;
|
||||
|
||||
foreach ($this->loadFromJSONFile('/alpha2/' . $alpha2[0]) as $languageRaw) {
|
||||
if ($languageRaw['alpha_2'] === $alpha2) {
|
||||
$language = $this->arrayToEntry($languageRaw);
|
||||
}
|
||||
}
|
||||
|
||||
return $language;
|
||||
}
|
||||
|
||||
public function getByAlpha3(string $alpha3): ?Language
|
||||
{
|
||||
$language = null;
|
||||
|
||||
foreach ($this->loadFromJSONFile('/alpha3/' . substr($alpha3, 0, 2)) as $languageRaw) {
|
||||
if ($languageRaw['alpha_3'] === $alpha3) {
|
||||
$language = $this->arrayToEntry($languageRaw);
|
||||
}
|
||||
}
|
||||
|
||||
return $language;
|
||||
}
|
||||
}
|
||||
73
vendor/sokil/php-isocodes/src/Database/Scripts.php
vendored
Normal file
73
vendor/sokil/php-isocodes/src/Database/Scripts.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database;
|
||||
|
||||
use Sokil\IsoCodes\AbstractNotPartitionedDatabase;
|
||||
use Sokil\IsoCodes\Database\Scripts\Script;
|
||||
|
||||
/**
|
||||
* @method Script|null find(string $indexedFieldName, string $fieldValue)
|
||||
*/
|
||||
class Scripts extends AbstractNotPartitionedDatabase
|
||||
{
|
||||
/**
|
||||
* ISO Standard Number
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public static function getISONumber(): string
|
||||
{
|
||||
return '15924';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $entry
|
||||
*
|
||||
*/
|
||||
protected function arrayToEntry(array $entry): Script
|
||||
{
|
||||
return new Script(
|
||||
$this->translationDriver,
|
||||
$entry['name'],
|
||||
$entry['alpha_4'],
|
||||
$entry['numeric']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getIndexDefinition(): array
|
||||
{
|
||||
return [
|
||||
'alpha_4',
|
||||
'numeric'
|
||||
];
|
||||
}
|
||||
|
||||
public function getByAlpha4(string $alpha4): ?Script
|
||||
{
|
||||
return $this->find('alpha_4', $alpha4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Using int code argument is deprecated due to it can be with leading 0 (e.g. '042').
|
||||
* Please, use numeric strings.
|
||||
*
|
||||
* @param string|int $code
|
||||
*
|
||||
* @return Script|null
|
||||
*
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public function getByNumericCode($code): ?Script
|
||||
{
|
||||
if (!is_numeric($code)) {
|
||||
throw new \TypeError('Argument must be int or string');
|
||||
}
|
||||
|
||||
return $this->find('numeric', (string)$code);
|
||||
}
|
||||
}
|
||||
75
vendor/sokil/php-isocodes/src/Database/Scripts/Script.php
vendored
Normal file
75
vendor/sokil/php-isocodes/src/Database/Scripts/Script.php
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database\Scripts;
|
||||
|
||||
use Sokil\IsoCodes\Database\Scripts;
|
||||
use Sokil\IsoCodes\TranslationDriver\TranslatorInterface;
|
||||
|
||||
class Script
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $localName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $alpha4;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $numericCode;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
private $translator;
|
||||
|
||||
public function __construct(
|
||||
TranslatorInterface $translator,
|
||||
string $name,
|
||||
string $alpha4,
|
||||
string $numericCode
|
||||
) {
|
||||
$this->translator = $translator;
|
||||
$this->name = $name;
|
||||
$this->alpha4 = $alpha4;
|
||||
$this->numericCode = $numericCode;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getLocalName(): string
|
||||
{
|
||||
if ($this->localName === null) {
|
||||
$this->localName = $this->translator->translate(
|
||||
Scripts::getISONumber(),
|
||||
$this->name
|
||||
);
|
||||
}
|
||||
|
||||
return $this->localName;
|
||||
}
|
||||
|
||||
public function getAlpha4(): string
|
||||
{
|
||||
return $this->alpha4;
|
||||
}
|
||||
|
||||
public function getNumericCode(): string
|
||||
{
|
||||
return $this->numericCode;
|
||||
}
|
||||
}
|
||||
77
vendor/sokil/php-isocodes/src/Database/Subdivisions.php
vendored
Normal file
77
vendor/sokil/php-isocodes/src/Database/Subdivisions.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database;
|
||||
|
||||
use Sokil\IsoCodes\AbstractNotPartitionedDatabase;
|
||||
use Sokil\IsoCodes\Database\Subdivisions\Subdivision;
|
||||
|
||||
/**
|
||||
* @method Subdivision|Subdivision[]|null find(string $indexedFieldName, string $fieldValue)
|
||||
*/
|
||||
class Subdivisions extends AbstractNotPartitionedDatabase implements SubdivisionsInterface
|
||||
{
|
||||
/**
|
||||
* ISO Standard Number
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public static function getISONumber(): string
|
||||
{
|
||||
return '3166-2';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $entry
|
||||
*/
|
||||
protected function arrayToEntry(array $entry): Subdivision
|
||||
{
|
||||
return new Subdivision(
|
||||
$this->translationDriver,
|
||||
$entry['name'],
|
||||
$entry['code'],
|
||||
$entry['type'],
|
||||
!empty($entry['parent']) ? $entry['parent'] : null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
protected function getIndexDefinition(): array
|
||||
{
|
||||
return [
|
||||
'code',
|
||||
'country_code' => [['code', 2], 'code'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subdivisionCode in format "alpha2country-subdivision", e.g. "UA-43"
|
||||
*/
|
||||
public function getByCode(string $subdivisionCode): ?Subdivision
|
||||
{
|
||||
/** @var Subdivision|null $subdivision */
|
||||
$subdivision = $this->find('code', $subdivisionCode);
|
||||
|
||||
return $subdivision;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $alpha2CountryCode e.g. "UA"
|
||||
*
|
||||
* @return Subdivision[]
|
||||
*/
|
||||
public function getAllByCountryCode(string $alpha2CountryCode): array
|
||||
{
|
||||
/** @var Subdivision[]|null $subdivisions */
|
||||
$subdivisions = $this->find('country_code', $alpha2CountryCode);
|
||||
|
||||
if (empty($subdivisions)) {
|
||||
$subdivisions = [];
|
||||
}
|
||||
|
||||
return $subdivisions;
|
||||
}
|
||||
}
|
||||
87
vendor/sokil/php-isocodes/src/Database/Subdivisions/Subdivision.php
vendored
Normal file
87
vendor/sokil/php-isocodes/src/Database/Subdivisions/Subdivision.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database\Subdivisions;
|
||||
|
||||
use Sokil\IsoCodes\Database\Subdivisions;
|
||||
use Sokil\IsoCodes\TranslationDriver\TranslatorInterface;
|
||||
|
||||
class Subdivision
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $localName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $parent;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
private $translator;
|
||||
|
||||
public function __construct(
|
||||
TranslatorInterface $translator,
|
||||
string $name,
|
||||
string $code,
|
||||
string $type,
|
||||
?string $parent = null
|
||||
) {
|
||||
$this->translator = $translator;
|
||||
$this->name = $name;
|
||||
$this->code = $code;
|
||||
$this->type = $type;
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getLocalName(): string
|
||||
{
|
||||
if ($this->localName === null) {
|
||||
$this->localName = $this->translator->translate(
|
||||
Subdivisions::getISONumber(),
|
||||
$this->name
|
||||
);
|
||||
}
|
||||
|
||||
return $this->localName;
|
||||
}
|
||||
|
||||
public function getCode(): string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getParent(): ?string
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
}
|
||||
22
vendor/sokil/php-isocodes/src/Database/SubdivisionsInterface.php
vendored
Normal file
22
vendor/sokil/php-isocodes/src/Database/SubdivisionsInterface.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database;
|
||||
|
||||
use Sokil\IsoCodes\Database\Subdivisions\Subdivision;
|
||||
|
||||
interface SubdivisionsInterface extends \Iterator, \Countable
|
||||
{
|
||||
/**
|
||||
* @param string $subdivisionCode in format "alpha2country-subdivision", e.g. "UA-43"
|
||||
*/
|
||||
public function getByCode(string $subdivisionCode): ?Subdivision;
|
||||
|
||||
/**
|
||||
* @param string $alpha2CountryCode e.g. "UA"
|
||||
*
|
||||
* @return Subdivision[]
|
||||
*/
|
||||
public function getAllByCountryCode(string $alpha2CountryCode): array;
|
||||
}
|
||||
64
vendor/sokil/php-isocodes/src/Database/SubdivisionsPartitioned.php
vendored
Normal file
64
vendor/sokil/php-isocodes/src/Database/SubdivisionsPartitioned.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sokil\IsoCodes\Database;
|
||||
|
||||
use Sokil\IsoCodes\AbstractPartitionedDatabase;
|
||||
use Sokil\IsoCodes\Database\Subdivisions\Subdivision;
|
||||
|
||||
class SubdivisionsPartitioned extends AbstractPartitionedDatabase implements SubdivisionsInterface
|
||||
{
|
||||
/**
|
||||
* ISO Standard Number
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public static function getISONumber(): string
|
||||
{
|
||||
return '3166-2';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $entry
|
||||
*/
|
||||
protected function arrayToEntry(array $entry): Subdivision
|
||||
{
|
||||
return new Subdivision(
|
||||
$this->translationDriver,
|
||||
$entry['name'],
|
||||
$entry['code'],
|
||||
$entry['type'],
|
||||
!empty($entry['parent']) ? $entry['parent'] : null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subdivisionCode in format "alpha2country-subdivision", e.g. "UA-43"
|
||||
*/
|
||||
public function getByCode(string $subdivisionCode): ?Subdivision
|
||||
{
|
||||
if (strpos($subdivisionCode, '-') === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
[$alpha2CountryCode] = explode('-', $subdivisionCode);
|
||||
|
||||
return $this->getAllByCountryCode($alpha2CountryCode)[$subdivisionCode] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $alpha2CountryCode e.g. "UA"
|
||||
*
|
||||
* @return Subdivision[]
|
||||
*/
|
||||
public function getAllByCountryCode(string $alpha2CountryCode): array
|
||||
{
|
||||
$subdivisions = [];
|
||||
foreach ($this->loadFromJSONFile($alpha2CountryCode) as $subdivision) {
|
||||
$subdivisions[$subdivision['code']] = $this->arrayToEntry($subdivision);
|
||||
}
|
||||
|
||||
return $subdivisions;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user