/home/mip/mip/public/img/credit/datatables/Aspects.tar
PhoneNumberType.php 0000644 00000002632 15152066236 0010352 0 ustar 00 <?php
namespace Propaganistas\LaravelPhone\Aspects;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use libphonenumber\PhoneNumberType as libPhoneNumberType;
use ReflectionClass;
class PhoneNumberType
{
public static function all(): array
{
return (new ReflectionClass(libPhoneNumberType::class))->getConstants();
}
public static function isValid($type): bool
{
return ! is_null($type) && in_array($type, static::all(), true);
}
public static function isValidName($type): bool
{
return ! is_null($type) && in_array($type, array_keys(static::all()), true);
}
public static function getHumanReadableName($type): string|null
{
$name = array_search($type, static::all(), true);
return $name ? strtolower($name) : null;
}
public static function sanitize($types): int|array|null
{
$sanitized = Collection::make(is_array($types) ? $types : [$types])
->map(function ($format) {
// If the type equals a constant's name, return its value.
// Otherwise just return the value.
return Arr::get(static::all(), strtoupper($format), $format);
})
->filter(function ($format) {
return static::isValid($format);
})->unique();
return is_array($types) ? $sanitized->toArray() : $sanitized->first();
}
}
PhoneNumberCountry.php 0000644 00000001574 15152066236 0011100 0 ustar 00 <?php
namespace Propaganistas\LaravelPhone\Aspects;
use Illuminate\Support\Collection;
use libphonenumber\PhoneNumberUtil;
class PhoneNumberCountry
{
public static function all(): array
{
return array_map('strtoupper', PhoneNumberUtil::getInstance()->getSupportedRegions());
}
public static function isValid($code): bool
{
return ! is_null($code) && in_array(strtoupper($code), static::all());
}
public static function sanitize($countries): string|array|null
{
$sanitized = Collection::make(is_array($countries) ? $countries : [$countries])
->filter(function ($value) {
return static::isValid($value);
})->map(function ($value) {
return strtoupper($value);
})->unique();
return is_array($countries) ? $sanitized->toArray() : $sanitized->first();
}
}
PhoneNumberFormat.php 0000644 00000002676 15152066236 0010671 0 ustar 00 <?php
namespace Propaganistas\LaravelPhone\Aspects;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use libphonenumber\PhoneNumberFormat as libPhoneNumberFormat;
use ReflectionClass;
class PhoneNumberFormat
{
public static function all(): array
{
return (new ReflectionClass(libPhoneNumberFormat::class))->getConstants();
}
public static function isValid($format): bool
{
return ! is_null($format) && in_array($format, static::all(), true);
}
public static function isValidName($format): bool
{
return ! is_null($format) && in_array($format, array_keys(static::all()), true);
}
public static function getHumanReadableName($format): string|null
{
$name = array_search($format, static::all(), true);
return $name ? strtolower($name) : null;
}
public static function sanitize($formats): int|array|null
{
$sanitized = Collection::make(is_array($formats) ? $formats : [$formats])
->map(function ($format) {
// If the format equals a constant's name, return its value.
// Otherwise just return the value.
return Arr::get(static::all(), strtoupper($format), $format);
})
->filter(function ($format) {
return static::isValid($format);
})->unique();
return is_array($formats) ? $sanitized->toArray() : $sanitized->first();
}
}