Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .codeclimate.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI
on:
- pull_request
- push
jobs:
psalm:
name: Psalm
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
coverage: none
- name: Composer install
run: composer install --no-interaction --no-ansi --no-progress
- name: Run Psalm
run: vendor/bin/psalm --no-progress --shepherd --show-info=false --stats
phpunit:
name: "PHPUnit (PHP: ${{ matrix.php-versions }})"
runs-on: ubuntu-latest
strategy:
matrix:
php-versions:
- 8.0
- 8.1
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
- name: Composer install
run: composer install --no-interaction --no-ansi --no-progress
- name: Run PHPUnit
run: vendor/bin/phpunit
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

PHP Library for manipulating network addresses (IPv4 and IPv6).

[![Build Status](https://travis-ci.org/S1lentium/IPTools.svg)](https://travis-ci.org/S1lentium/IPTools)
[![Coverage Status](https://coveralls.io/repos/S1lentium/IPTools/badge.svg?branch=master&service=github)](https://coveralls.io/github/S1lentium/IPTools?branch=master)
[![Code Climate](https://codeclimate.com/github/S1lentium/IPTools/badges/gpa.svg)](https://codeclimate.com/github/S1lentium/IPTools)

[![PHP 5.6](https://img.shields.io/badge/PHP-5.6-8892BF.svg)](http://php.net)
[![PHP 7.0](https://img.shields.io/badge/PHP-7.0-8892BF.svg)](http://php.net)

## Installation
Composer:
Run in command line:
Expand Down
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "s1lentium/iptools",
"name": "artemeon/iptools",
"type": "library",
"description": "PHP Library for manipulating network addresses (IPv4 and IPv6)",
"keywords": ["IP-Tools", "network", "subnet", "cidr", "IP", "IPv4", "IPv6"],
Expand All @@ -10,16 +10,21 @@
"homepage": "https://github.com/S1lentium"
}],
"require": {
"php": ">=5.4.0",
"php": ">=8.0",
"ext-bcmath": "*"
},
"require-dev": {
"satooshi/php-coveralls": "~1.0",
"phpunit/phpunit": "~4.0"
"phpunit/phpunit": "~9.0",
"vimeo/psalm": "^4.0"
},
"autoload": {
"psr-4": {
"IPTools\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"IPTools\\Tests\\": "tests/"
}
}
}
43 changes: 12 additions & 31 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/bootstrap.php"
>
<testsuites>
<testsuite name="IPTools Test Suite">
<directory suffix=".php">./tests</directory>
</testsuite>
</testsuites>

<logging>
<log type="coverage-html" target="./coverage" lowUpperBound="50" highLowerBound="80"/>
</logging>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
<exclude>
<file>./src/PropertyTrait.php</file>
</exclude>
</whitelist>
</filter>
</phpunit>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="IPTools Test Suite">
<directory suffix=".php">./tests</directory>
</testsuite>
</testsuites>
</phpunit>
15 changes: 15 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<psalm
errorLevel="7"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
30 changes: 14 additions & 16 deletions tests/IPTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php

namespace IPTools\Tests;

use IPTools\Exception\IpException;
use IPTools\IP;
use PHPUnit\Framework\TestCase;

class IPTest extends \PHPUnit_Framework_TestCase
class IPTest extends TestCase
{
public function testConstructor()
{
Expand All @@ -25,12 +29,12 @@ public function testConstructor()

/**
* @dataProvider getTestContructorExceptionData
* @expectedException Exception
* @expectedExceptionMessage Invalid IP address format
*/
public function testConstructorException($string)
{
$ip = new IP($string);
$this->expectException(IpException::class);

new IP($string);
}

public function testProperties()
Expand Down Expand Up @@ -76,12 +80,10 @@ public function testParseBin($bin, $expectedString)
$this->assertEquals($bin, $ip->toBin());
}

/**
* @expectedException Exception
* @expectedExceptionMessage Invalid binary IP address format
*/
public function testParseBinException()
{
$this->expectException(IpException::class);

IP::parseBin('192.168.1.1');
}

Expand Down Expand Up @@ -110,12 +112,10 @@ public function testParseHex()

}

/**
* @expectedException Exception
* @expectedExceptionMessage Invalid hexadecimal IP address format
*/
public function testParseHexException()
{
$this->expectException(IpException::class);

IP::parseHex('192.168.1.1');
}

Expand Down Expand Up @@ -154,12 +154,10 @@ public function testPrev($ip, $step, $expected)
$this->assertEquals($expected, (string) $prev);
}

/**
* @expectedException Exception
* @expectedExceptionMessage Number must be greater than 0
*/
public function testPrevException()
{
$this->expectException(IpException::class);

$object = new IP('192.168.1.1');
$object->prev(-1);
}
Expand Down
33 changes: 17 additions & 16 deletions tests/NetworkTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?php

use IPTools\Network;
namespace IPTools\Tests;

use IPTools\Exception\IpException;
use IPTools\Exception\NetworkException;
use IPTools\IP;
use IPTools\Network;
use PHPUnit\Framework\TestCase;

class NetworkTest extends \PHPUnit_Framework_TestCase
class NetworkTest extends TestCase
{
public function testConstructor()
{
Expand Down Expand Up @@ -41,12 +46,10 @@ public function testParse($data, $expected)
$this->assertEquals($expected, (string)Network::parse($data));
}

/**
* @expectedException Exception
* @expectedExceptionMessage Invalid IP address format
*/
public function testParseWrongNetwork()
{
$this->expectException(IpException::class);

Network::parse('10.0.0.0/24 abc');
}

Expand All @@ -58,22 +61,20 @@ public function testPrefix2Mask($prefix, $version, $mask)
$this->assertEquals($mask, Network::prefix2netmask($prefix, $version));
}

/**
* @expectedException Exception
* @expectedExceptionMessage Wrong IP version
*/
public function testPrefix2MaskWrongIPVersion()
{
$this->expectException(NetworkException::class);

Network::prefix2netmask('128', 'ip_version');
}

/**
* @dataProvider getInvalidPrefixData
* @expectedException Exception
* @expectedExceptionMessage Invalid prefix length
*/
public function testPrefix2MaskInvalidPrefix($prefix, $version)
{
$this->expectException(NetworkException::class);

Network::prefix2netmask($prefix, $version);
}

Expand Down Expand Up @@ -105,11 +106,11 @@ public function testExclude($data, $exclude, $expected)

/**
* @dataProvider getExcludeExceptionData
* @expectedException Exception
* @expectedExceptionMessage Exclude subnet not within target network
*/
public function testExcludeException($data, $exclude)
{
$this->expectException(NetworkException::class);

Network::parse($data)->exclude($exclude);
}

Expand All @@ -129,11 +130,11 @@ public function testMoveTo($network, $prefixLength, $expected)

/**
* @dataProvider getMoveToExceptionData
* @expectedException Exception
* @expectedExceptionMessage Invalid prefix length
*/
public function testMoveToException($network, $prefixLength)
{
$this->expectException(NetworkException::class);

Network::parse($network)->moveTo($prefixLength);
}

Expand Down
8 changes: 5 additions & 3 deletions tests/RangeTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

use IPTools\Range;
use IPTools\Network;
namespace IPTools\Tests;

use IPTools\IP;
use IPTools\Range;
use PHPUnit\Framework\TestCase;

class RangeTest extends \PHPUnit_Framework_TestCase
class RangeTest extends TestCase
{
/**
* @dataProvider getTestParseData
Expand Down
10 changes: 0 additions & 10 deletions tests/bootstrap.php

This file was deleted.