1 | <?php |
||
7 | class CompressionFactory |
||
8 | { |
||
9 | const TYPE_NONE = 'none'; |
||
10 | const TYPE_UNKNOWN = 'unknown'; |
||
11 | |||
12 | /** |
||
13 | * @var CompressionTypeInterface[] |
||
14 | */ |
||
15 | private $compressors; |
||
16 | |||
17 | /** |
||
18 | * @var CompressionTypeInterface[] |
||
19 | */ |
||
20 | private $deCompressors; |
||
21 | |||
22 | 14 | public function __construct() |
|
33 | |||
34 | /** |
||
35 | * @param CompressionTypeInterface $type |
||
36 | * |
||
37 | * @return static |
||
|
|||
38 | */ |
||
39 | 14 | public function addCompressor(CompressionTypeInterface $type) |
|
43 | |||
44 | /** |
||
45 | * @param CompressionTypeInterface $type |
||
46 | * |
||
47 | * @return static |
||
48 | */ |
||
49 | 14 | public function addDeCompressor(CompressionTypeInterface $type) |
|
53 | |||
54 | /** |
||
55 | * Check if the specified $compression is valid or not |
||
56 | * |
||
57 | * @param string $compression |
||
58 | * |
||
59 | * @return bool |
||
60 | */ |
||
61 | 3 | public function isCompression($compression) |
|
65 | |||
66 | /** |
||
67 | * @param string $compression |
||
68 | * |
||
69 | * @return CompressorInterface |
||
70 | * @throws InvalidCompressionTypeException |
||
71 | */ |
||
72 | 5 | public function getCompressor($compression) |
|
80 | |||
81 | /** |
||
82 | * @param string $compression CompressionType:: |
||
83 | * |
||
84 | * @return DeCompressorInterface |
||
85 | * @throws InvalidCompressionTypeException |
||
86 | */ |
||
87 | 7 | public function getDeCompressor($compression) |
|
95 | } |
||
96 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.