Skip to content

Commit 4f9fe8b

Browse files
temppl-github
authored andcommitted
allow symfony 3, use phpunit 6, raise minimum php version to 7.1, ref… (#11)
* allow symfony 3, use phpunit 6, raise minimum php version to 7.1, refactorings and bugfixes * fix travis config
1 parent 5c342da commit 4f9fe8b

Some content is hidden

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

42 files changed

+351
-485
lines changed

.travis.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
language: php
22

33
php:
4-
- 5.5
5-
- 5.6
6-
- 7
7-
- hhvm
4+
- 7.1
5+
- nightly
6+
7+
matrix:
8+
allow_failures:
9+
- php:
10+
- nightly
811

912
before_install:
1013
- sudo apt-get update -qq
1114
- sudo apt-get install -y p7zip-full
1215

1316
before_script: composer install
1417

15-
script: vendor/bin/phpunit -c tests --coverage-clover=coverage.clover
18+
script: vendor/bin/phpunit tests --coverage-clover=coverage.clover
1619

1720
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;'
21+
- sh -c 'if [ $(phpenv version-name) = "7.1" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi;'

CHANGELOG

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3.0
2+
3+
- DecoderResolver::addDecoder() is now private
4+
- EncoderResolver::addDecoder() is now private

composer.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,22 @@
1919
}
2020
],
2121
"require": {
22-
"php": ">=5.4.0",
23-
"psr/log": "~1.0",
24-
"symfony/process": "~2.3"
22+
"php": "^7.1",
23+
"psr/log": "^1.0",
24+
"symfony/process": "^2.8|^3.0"
2525
},
2626
"require-dev": {
27-
"php": ">=5.5.0",
28-
"phpunit/phpunit": "~4.5"
27+
"phpunit/phpunit": "^6.0"
2928
},
3029
"autoload": {
3130
"psr-4": { "Brainbits\\Transcoder\\": "src/" }
3231
},
3332
"autoload-dev": {
3433
"psr-4": { "Brainbits\\Transcoder\\Tests\\": "tests/" }
34+
},
35+
"extra": {
36+
"branch-alias": {
37+
"dev-master": "3.0-dev"
38+
}
3539
}
3640
}

tests/phpunit.xml.dist phpunit.xml.dist

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
convertNoticesToExceptions="true"
66
convertWarningsToExceptions="true"
77
syntaxCheck="true">
8-
<testsuite name="brainbits">
9-
<directory>.</directory>
8+
<testsuite name="transcoder">
9+
<directory>tests</directory>
1010
</testsuite>
1111
<filter>
1212
<whitelist>
13-
<directory suffix=".php">../src/</directory>
13+
<directory suffix=".php">src/</directory>
1414
</whitelist>
1515
</filter>
1616
</phpunit>

src/Decoder/Bzip2Decoder.php

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types = 1);
4+
35
/*
46
* This file is part of the brainbits transcoder package.
57
*
@@ -14,18 +16,13 @@
1416
use Brainbits\Transcoder\Exception\DecodeFailedException;
1517

1618
/**
17-
* Bzip2 decoder
18-
*
19-
* @author Gregor Welters <[email protected]>
19+
* Bzip2 decoder.
2020
*/
2121
class Bzip2Decoder implements DecoderInterface
2222
{
2323
const TYPE = 'bzip2';
2424

25-
/**
26-
* @inheritDoc
27-
*/
28-
public function decode($data)
25+
public function decode(string $data): string
2926
{
3027
$data = bzdecompress($data);
3128

@@ -40,10 +37,7 @@ public function decode($data)
4037
return $data;
4138
}
4239

43-
/**
44-
* @inheritDoc
45-
*/
46-
public function supports($type)
40+
public function supports(?string $type): bool
4741
{
4842
return self::TYPE === $type;
4943
}
@@ -53,7 +47,7 @@ public function supports($type)
5347
*
5448
* @return bool
5549
*/
56-
private function isErrorCode($result)
50+
private function isErrorCode($result): bool
5751
{
5852
return $result === -1 || $result === -2 || $result === -3 || $result === -5 || $result === -6 ||
5953
$result === -7 || $result === -8 || $result === -9;

src/Decoder/DecoderInterface.php

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types = 1);
4+
35
/*
46
* This file is part of the brainbits transcoder package.
57
*
@@ -12,25 +14,17 @@
1214
namespace Brainbits\Transcoder\Decoder;
1315

1416
/**
15-
* Decoder interface
16-
*
17-
* @author Gregor Welters <[email protected]>
17+
* Decoder interface.
1818
*/
1919
interface DecoderInterface
2020
{
2121
/**
22-
* Decode data
23-
*
24-
* @param string $data
25-
* @return string
22+
* Decode data.
2623
*/
27-
public function decode($data);
24+
public function decode(string $data): string;
2825

2926
/**
30-
* Returns true if type is supported, false otherwise
31-
*
32-
* @param string $type
33-
* @return boolean
27+
* Returns true if type is supported, false otherwise.
3428
*/
35-
public function supports($type);
29+
public function supports(?string $type): bool;
3630
}

src/Decoder/DecoderResolver.php

+16-25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types = 1);
4+
35
/*
46
* This file is part of the brainbits transcoder package.
57
*
@@ -11,12 +13,11 @@
1113

1214
namespace Brainbits\Transcoder\Decoder;
1315

16+
use RuntimeException;
17+
1418
/**
15-
* Decoder resolver
16-
* Resolves decoders based on supported type
17-
*
18-
* @author Stephan Wentz <[email protected]>
19-
* @author Gregor Welters <[email protected]>
19+
* Decoder resolver.
20+
* Resolves decoders based on supported type.
2021
*/
2122
class DecoderResolver implements DecoderResolverInterface
2223
{
@@ -30,34 +31,24 @@ class DecoderResolver implements DecoderResolverInterface
3031
*/
3132
public function __construct(array $decoders = array())
3233
{
33-
$this->decoders = $decoders;
34-
}
35-
36-
/**
37-
* Add decoder
38-
*
39-
* @param DecoderInterface $decoder
40-
* @return $this
41-
*/
42-
public function addDecoder(DecoderInterface $decoder)
43-
{
44-
$this->decoders[] = $decoder;
45-
46-
return $this;
34+
foreach ($decoders as $decoder) {
35+
$this->addDecoder($decoder);
36+
}
4737
}
4838

49-
/**
50-
* @inheritDoc
51-
* @throws \RuntimeException
52-
*/
53-
public function resolve($type)
39+
public function resolve(?string $type): DecoderInterface
5440
{
5541
foreach ($this->decoders as $decoder) {
5642
if ($decoder->supports($type)) {
5743
return $decoder;
5844
}
5945
}
6046

61-
throw new \RuntimeException("No decoder supports the requested type $type");
47+
throw new RuntimeException("No decoder supports the requested type $type");
48+
}
49+
50+
private function addDecoder(DecoderInterface $decoder): void
51+
{
52+
$this->decoders[] = $decoder;
6253
}
6354
}
+5-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types = 1);
4+
35
/*
46
* This file is part of the brainbits transcoder package.
57
*
@@ -12,16 +14,10 @@
1214
namespace Brainbits\Transcoder\Decoder;
1315

1416
/**
15-
* Decoder resolver interface
16-
* Resolves decoders based on supported type
17-
*
18-
* @author Stephan Wentz <[email protected]>
17+
* Decoder resolver interface.
18+
* Resolves decoders based on supported type.
1919
*/
2020
interface DecoderResolverInterface
2121
{
22-
/**
23-
* @param string|null $type
24-
* @return DecoderInterface
25-
*/
26-
public function resolve($type);
22+
public function resolve(?string $type): DecoderInterface;
2723
}

src/Decoder/DeflateDecoder.php

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types = 1);
4+
35
/*
46
* This file is part of the brainbits transcoder package.
57
*
@@ -14,18 +16,13 @@
1416
use Brainbits\Transcoder\Exception\DecodeFailedException;
1517

1618
/**
17-
* Deflate decoder
18-
*
19-
* @author Gregor Welters <[email protected]>
19+
* Deflate decoder.
2020
*/
2121
class DeflateDecoder implements DecoderInterface
2222
{
2323
const TYPE = 'deflate';
2424

25-
/**
26-
* @inheritDoc
27-
*/
28-
public function decode($data)
25+
public function decode(string $data): string
2926
{
3027
$data = gzinflate($data);
3128

@@ -36,10 +33,7 @@ public function decode($data)
3633
return $data;
3734
}
3835

39-
/**
40-
* @inheritDoc
41-
*/
42-
public function supports($type)
36+
public function supports(?string $type): bool
4337
{
4438
return self::TYPE === $type;
4539
}

src/Decoder/GzipDecoder.php

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types = 1);
4+
35
/*
46
* This file is part of the brainbits transcoder package.
57
*
@@ -14,18 +16,13 @@
1416
use Brainbits\Transcoder\Exception\DecodeFailedException;
1517

1618
/**
17-
* Gzip decoder
18-
*
19-
* @author Gregor Welters <[email protected]>
19+
* Gzip decoder.
2020
*/
2121
class GzipDecoder implements DecoderInterface
2222
{
2323
const TYPE = 'gzip';
2424

25-
/**
26-
* @inheritDoc
27-
*/
28-
public function decode($data)
25+
public function decode(string $data): string
2926
{
3027
$data = gzdecode($data);
3128

@@ -36,10 +33,7 @@ public function decode($data)
3633
return $data;
3734
}
3835

39-
/**
40-
* @inheritDoc
41-
*/
42-
public function supports($type)
36+
public function supports(?string $type): bool
4337
{
4438
return self::TYPE === $type;
4539
}

src/Decoder/NullDecoder.php

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types = 1);
4+
35
/*
46
* This file is part of the brainbits transcoder package.
57
*
@@ -12,26 +14,18 @@
1214
namespace Brainbits\Transcoder\Decoder;
1315

1416
/**
15-
* Null decoder
16-
*
17-
* @author Gregor Welters <[email protected]>
17+
* Null decoder.
1818
*/
1919
class NullDecoder implements DecoderInterface
2020
{
2121
const TYPE = 'null';
2222

23-
/**
24-
* @inheritDoc
25-
*/
26-
public function decode($data)
23+
public function decode(string $data): string
2724
{
2825
return $data;
2926
}
3027

31-
/**
32-
* @inheritDoc
33-
*/
34-
public function supports($type)
28+
public function supports(?string $type): bool
3529
{
3630
return null === $type || self::TYPE === $type;
3731
}

0 commit comments

Comments
 (0)