Skip to content

Commit 5b2427e

Browse files
authored
CleanUp before Refactoring (#3)
1 parent 202b336 commit 5b2427e

File tree

19 files changed

+163
-446
lines changed

19 files changed

+163
-446
lines changed

.github/workflows/php.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: ['ubuntu-latest']
16+
php-versions: [7.4, 8.0]
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php-versions }}
24+
extensions: soap
25+
26+
- name: Validate composer.json and composer.lock
27+
run: composer validate
28+
29+
- name: Cache Composer packages
30+
id: composer-cache
31+
uses: actions/cache@v2
32+
with:
33+
path: vendor
34+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
35+
restore-keys: |
36+
${{ runner.os }}-php-
37+
38+
- name: Install dependencies
39+
run: composer install --prefer-dist --no-progress --no-suggest
40+
41+
- name: Run test suite
42+
run: vendor/bin/codecept run

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@
1010
"type": "library",
1111
"license": "MIT",
1212
"require": {
13-
"php": ">=5.5.0",
14-
"ext-sqlite3": "*",
15-
"guzzlehttp/guzzle": "^6.2",
16-
"monolog/monolog": "^1.20 || ^2"
13+
"php": "^7.4 || ^8",
14+
"ext-sqlite3": "*"
1715
},
1816
"require-dev": {
19-
"codeception/codeception": "^3"
17+
"codeception/codeception": "^4"
2018
},
2119
"minimum-stability": "dev",
2220
"autoload": {
2321
"psr-4": {
2422
"Udger\\": "src/"
2523
}
24+
},
25+
"scripts": {
26+
"test": "vendor/bin/codecept run"
2627
}
2728
}

examples/account.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/parse.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Helper/IP.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,20 @@
88
*
99
* @author tiborb
1010
*/
11-
class IP implements IPInterface{
11+
class IP implements IPInterface
12+
{
1213

1314
/**
1415
* Get IP verison
15-
*
16+
*
1617
* @param string $ip
1718
* @return integer|boolean Returns version or false on invalid address
1819
*/
1920
public function getIpVersion($ip)
2021
{
2122
if (false !== filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
2223
return self::IPv6;
23-
}
24-
25-
else if (false !== filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
24+
} elseif (false !== filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
2625
return self::IPv4;
2726
}
2827
// invalid ip
@@ -31,7 +30,7 @@ public function getIpVersion($ip)
3130

3231
/**
3332
* Ip to long
34-
*
33+
*
3534
* @param string $ip
3635
* @return integer
3736
*/
@@ -43,22 +42,23 @@ public function getIpLong($ip)
4342

4443
/**
4544
* Ipv6 to array
46-
*
45+
*
4746
* @param string $ip
4847
* @return array
4948
*/
50-
public function getIp6array($ip){
51-
// expand - example: "2600:3c00::" -> "2600:3c00:0000:0000:0000:0000:0000:0000"
52-
$hex = unpack("H*hex", inet_pton($ip));
53-
$ipStr = substr(preg_replace("/([A-f0-9]{4})/", "$1:", $hex['hex']), 0, -1);
49+
public function getIp6array($ip)
50+
{
51+
// expand - example: "2600:3c00::" -> "2600:3c00:0000:0000:0000:0000:0000:0000"
52+
$hex = unpack("H*hex", inet_pton($ip));
53+
$ipStr = substr(preg_replace("/([A-f0-9]{4})/", "$1:", $hex['hex']), 0, -1);
5454

55-
$ipIntArray = array();
56-
$ipStrArray = explode(":", $ipStr);
55+
$ipIntArray = array();
56+
$ipStrArray = explode(":", $ipStr);
5757

58-
foreach ($ipStrArray as &$value) {
59-
$ipIntArray[] = hexdec($value);
60-
}
58+
foreach ($ipStrArray as &$value) {
59+
$ipIntArray[] = hexdec($value);
60+
}
6161

62-
return $ipIntArray;
62+
return $ipIntArray;
6363
}
6464
}

src/Helper/IPInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*
77
* @author tiborb
88
*/
9-
interface IPInterface {
10-
9+
interface IPInterface
10+
{
1111
const IPv4 = 4;
1212
const IPv6 = 6;
1313

0 commit comments

Comments
 (0)