Skip to content

Commit 8d48b37

Browse files
committed
Merge pull request #8 from temp/remove-assert
remove assert dependency, fix file headers, use prophecy for mocks
2 parents eb975e1 + 5cf5c95 commit 8d48b37

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+594
-383
lines changed

.scrutinizer.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tools:
2+
external_code_coverage:
3+
timeout: 600 # Timeout in seconds.

.travis.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
language: php
22

33
php:
4-
- 5.4
54
- 5.5
5+
- 5.6
6+
- 7
7+
- hhvm
68

7-
before_script: composer install --prefer-source
9+
before_install:
10+
- sudo apt-get update -qq
11+
- sudo apt-get install -y p7zip-full
812

9-
script: phpunit -c tests
13+
before_script: composer install
14+
15+
script: vendor/bin/phpunit -c tests --coverage-clover=coverage.clover
16+
17+
after_script:
18+
- sh -c 'if [ $(phpenv version-name) = "5.6" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi;'

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2012-2013 brainbits GmbH (http://www.brainbits.net)
1+
Copyright (c) 2012-2016 brainbits GmbH (http://www.brainbits.net)
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1616
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1717
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1818
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19-
THE SOFTWARE.
19+
THE SOFTWARE.

composer.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@
1212
{
1313
"name": "Phillip Look",
1414
"email": "plook@brainbits.net"
15+
},
16+
{
17+
"name": "Stephan Wentz",
18+
"email": "swentz@brainbits.net"
1519
}
1620
],
1721
"require": {
18-
"php": ">=5.3.0",
19-
"beberlei/assert": "1.*",
20-
"symfony/http-kernel": "2.3.*",
21-
"symfony/process": "2.3.*"
22+
"php": ">=5.5.0",
23+
"psr/log": "~1.0",
24+
"symfony/process": "~2.3"
25+
},
26+
"require-dev": {
27+
"phpunit/phpunit": "~4.5"
2228
},
2329
"autoload": {
24-
"psr-0": { "Brainbits": "src/" }
30+
"psr-4": { "Brainbits\\Transcoder\\": "src/" }
2531
},
26-
"minimum-stability": "stable"
32+
"autoload-dev": {
33+
"psr-4": { "Brainbits\\Transcoder\\Tests\\": "tests/" }
34+
}
2735
}

src/Brainbits/Transcoder/Tests/TranscoderTestHelper.php

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

src/Brainbits/Transcoder/Decoder/Bzip2Decoder.php renamed to src/Decoder/Bzip2Decoder.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<?php
2-
/**
2+
3+
/*
34
* This file is part of the brainbits transcoder package.
45
*
5-
* (c) 2012-2013 brainbits GmbH (http://www.brainbits.net)
6+
* (c) brainbits GmbH
67
*
78
* For the full copyright and license information, please view the LICENSE
89
* file that was distributed with this source code.
910
*/
1011

1112
namespace Brainbits\Transcoder\Decoder;
1213

13-
use Assert\Assertion;
14+
use Brainbits\Transcoder\Exception\DecodeFailedException;
1415

1516
/**
1617
* Bzip2 decoder
@@ -27,7 +28,15 @@ class Bzip2Decoder implements DecoderInterface
2728
public function decode($data)
2829
{
2930
$data = bzdecompress($data);
30-
Assertion::minLength($data, 1, 'bzdecompress returned no data');
31+
32+
if ($this->isErrorCode($data)) {
33+
throw new DecodeFailedException("bzdecompress failed.");
34+
}
35+
36+
if (!$data) {
37+
throw new DecodeFailedException("bzdecompress returned no data.");
38+
}
39+
3140
return $data;
3241
}
3342

@@ -38,4 +47,15 @@ public function supports($type)
3847
{
3948
return self::TYPE === $type;
4049
}
50+
51+
/**
52+
* @param mixed $result
53+
*
54+
* @return bool
55+
*/
56+
private function isErrorCode($result)
57+
{
58+
return $result === -1 || $result === -2 || $result === -3 || $result === -5 || $result === -6 ||
59+
$result === -7 || $result === -8 || $result === -9;
60+
}
4161
}

src/Brainbits/Transcoder/Decoder/DecoderInterface.php renamed to src/Decoder/DecoderInterface.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
2-
/**
2+
3+
/*
34
* This file is part of the brainbits transcoder package.
45
*
5-
* (c) 2012-2013 brainbits GmbH (http://www.brainbits.net)
6+
* (c) brainbits GmbH
67
*
78
* For the full copyright and license information, please view the LICENSE
89
* file that was distributed with this source code.

src/Brainbits/Transcoder/Decoder/DecoderResolver.php renamed to src/Decoder/DecoderResolver.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
2-
/**
2+
3+
/*
34
* This file is part of the brainbits transcoder package.
45
*
5-
* (c) 2012-2013 brainbits GmbH (http://www.brainbits.net)
6+
* (c) brainbits GmbH
67
*
78
* For the full copyright and license information, please view the LICENSE
89
* file that was distributed with this source code.

src/Brainbits/Transcoder/Decoder/DecoderResolverInterface.php renamed to src/Decoder/DecoderResolverInterface.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
2-
/**
2+
3+
/*
34
* This file is part of the brainbits transcoder package.
45
*
5-
* (c) 2012-2013 brainbits GmbH (http://www.brainbits.net)
6+
* (c) brainbits GmbH
67
*
78
* For the full copyright and license information, please view the LICENSE
89
* file that was distributed with this source code.

src/Brainbits/Transcoder/Decoder/DeflateDecoder.php renamed to src/Decoder/DeflateDecoder.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<?php
2-
/**
2+
3+
/*
34
* This file is part of the brainbits transcoder package.
45
*
5-
* (c) 2012-2013 brainbits GmbH (http://www.brainbits.net)
6+
* (c) brainbits GmbH
67
*
78
* For the full copyright and license information, please view the LICENSE
89
* file that was distributed with this source code.
910
*/
1011

1112
namespace Brainbits\Transcoder\Decoder;
1213

13-
use Assert\Assertion;
14+
use Brainbits\Transcoder\Exception\DecodeFailedException;
1415

1516
/**
1617
* Deflate decoder
@@ -27,7 +28,11 @@ class DeflateDecoder implements DecoderInterface
2728
public function decode($data)
2829
{
2930
$data = gzinflate($data);
30-
Assertion::minLength($data, 1, 'gzinflate returned no data');
31+
32+
if (!$data) {
33+
throw new DecodeFailedException("gzinflate returned no data.");
34+
}
35+
3136
return $data;
3237
}
3338

0 commit comments

Comments
 (0)