Skip to content

Commit

Permalink
fix validator
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinKuklin committed Apr 7, 2018
1 parent 7d7a2cf commit f35c376
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
@@ -1,10 +1,12 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm

before_script:
Expand All @@ -15,4 +17,4 @@ after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover

script: phpunit --coverage-clover=coverage.clover
script: ./vendor/bin/phpunit --coverage-clover=coverage.clover
7 changes: 5 additions & 2 deletions composer.json
Expand Up @@ -13,9 +13,12 @@
],
"require": {
"php": ">=5.3.2",
"respect/validation": "*"
"respect/validation": "^1.1.15"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35"
},
"autoload": {
"psr-0": {"Stream": "src/"}
}
}
}
10 changes: 5 additions & 5 deletions src/Stream/Validator.php
Expand Up @@ -46,9 +46,9 @@ public static function validateProtocol($protocol)
*/
public static function validatePort($port)
{
if (!v::int()->between(0, 65635)->validate($port)) {
if (!v::intVal()->between(1, 65635)->validate($port)) {
throw new PortValidateStreamException(
sprintf("Port '%s' is not a integer number or not inside the range: 0-65535", $port)
sprintf("Port '%s' is not a integer number or not inside the range: 1-65535", $port)
);
}
}
Expand All @@ -72,7 +72,7 @@ public static function validatePath($path)
*/
public static function validateSeconds($seconds)
{
if (!v::int()->min(0, true)->validate($seconds)) {
if (!v::intVal()->min(0, true)->validate($seconds)) {
throw new StreamException(
sprintf("Seconds must be int >= 0, got %s with value %s.", gettype($seconds), $seconds)
);
Expand All @@ -86,10 +86,10 @@ public static function validateSeconds($seconds)
*/
public static function validateMicroSeconds($microSeconds)
{
if ($microSeconds !== 0 && !v::int()->min(0, true)->validate($microSeconds)) {
if ($microSeconds !== 0 && !v::intVal()->min(0, true)->validate($microSeconds)) {
throw new StreamException(
sprintf("Micro seconds must be int >= 0, got %s with value %s.", gettype($microSeconds), $microSeconds)
);
}
}
}
}
4 changes: 2 additions & 2 deletions tests/GetContentsTest.php
Expand Up @@ -84,6 +84,6 @@ public function testGetContentsWork()
$this->fail("Got wrong response.");
}

$this->assertEquals("HTTP/1.0 302 Found", trim($contents[0]), "Contents was got incorrect.");
$this->assertEquals("HTTP/1.0 404 Not Found", trim($contents[0]), "Contents was got incorrect.");
}
}
}

0 comments on commit f35c376

Please sign in to comment.