Skip to content

Commit

Permalink
Merge pull request #9 from yondifon/fix-union-type-hints-for-php7.4
Browse files Browse the repository at this point in the history
Remove Union type hints to enable php7.x support
  • Loading branch information
yondifon authored Sep 7, 2021
2 parents ddff279 + ac1e736 commit bbc6360
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 35 deletions.
52 changes: 29 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
{
"name": "malico/mobile-cm-php",
"description": "Get Telephone number's Mobile Network",
"license": "MIT",
"archive": {
"exclude": [
"tests"
]
},
"authors": [
{
"name": "Malico",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {
"Malico\\MobileCM\\": "src/"
}
},
"minimum-stability": "dev",
"require-dev": {
"pestphp/pest": "1.x-dev"
}
"name": "malico/mobile-cm-php",
"description": "Get Telephone number's Mobile Network",
"license": "MIT",
"archive": {
"exclude": [
"tests"
]
},
"authors": [
{
"name": "Malico",
"email": "[email protected]"
}
],
"scripts": {
"test": [
"php7.4 ./vendor/bin/pest",
"php8.0 ./vendor/bin/pest"
]
},
"autoload": {
"psr-4": {
"Malico\\MobileCM\\": "src/"
}
},
"minimum-stability": "dev",
"require-dev": {
"pestphp/pest": "1.x-dev"
}
}
24 changes: 12 additions & 12 deletions src/Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Network
*
* @return bool
*/
protected static function validLength($tel) : bool
protected static function validLength($tel): bool
{
$len = strlen($tel);

Expand All @@ -60,7 +60,7 @@ protected static function validLength($tel) : bool
*
* @return bool
*/
protected static function checkNumber(string | int $tel, $key)
protected static function checkNumber(string $tel, $key)
{
$tel = \str_replace(' ', '', (string) $tel);

Expand All @@ -81,59 +81,59 @@ protected static function checkNumber(string | int $tel, $key)
/**
* Check if Number is Orange.
*
* @param string | int $tel
* @param string $tel
*
* @return bool
*/
public static function isOrange(string | int $tel) : bool
public static function isOrange(string $tel): bool
{
return self::checkNumber($tel, 'orange');
}

/**
* Check if Number is MTN.
*
* @param string | int $tel
* @param string $tel
*
* @return bool
*/
public static function isMTN(string | int $tel) : bool
public static function isMTN(string $tel): bool
{
return self::checkNumber($tel, 'mtn');
}

/**
* Check if Number is Nexttel.
*
* @param string | int $tel
* @param string $tel
*
* @return bool
*/
public static function isNexttel(string | int $tel) : bool
public static function isNexttel(string $tel): bool
{
return self::checkNumber($tel, 'nexttel');
}

/**
* Check if Number is Camtel.
*
* @param string | int $tel
* @param string $tel
*
* @return bool
*/
public static function isCamtel(string | int $tel) : bool
public static function isCamtel(string $tel): bool
{
return self::checkNumber($tel, 'camtel');
}

/**
* Match Number to Operator.
*
* @param string | int $tel
* @param string $tel
*
* @return bool
*/
public static function check($tel) : string | null
public static function check($tel): string
{
foreach (self::OPERATOR_PREFIXES as $key => $value) {
if (self::checkNumber($tel, $key)) {
Expand Down

0 comments on commit bbc6360

Please sign in to comment.