1 | <?php |
||
22 | class LocalFile extends FileNode implements LocalFileNodeInterface, NodeStreamInterface, BuilderAwareInterface |
||
23 | { |
||
24 | use BuilderTrait; |
||
25 | |||
26 | /** |
||
27 | * @param string $path |
||
28 | */ |
||
29 | 108 | public function __construct($path) |
|
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | 20 | public function getContents() |
|
38 | { |
||
39 | 20 | if ($this->exists() && |
|
40 | 20 | !in_array($this->getCompression(), [CompressionFactory::TYPE_NONE, CompressionFactory::TYPE_UNKNOWN]) |
|
41 | ) { |
||
42 | /** @var CompressionFactory $factory */ |
||
43 | 2 | $factory = $this->getBuilder()->build(CompressionFactory::class); |
|
44 | 2 | $compressor = $factory->getDeCompressor($this->getCompression()); |
|
45 | 2 | $uncompressed = $compressor->decompress($this); |
|
46 | 2 | $content = $uncompressed->getContents(); |
|
47 | 2 | $uncompressed->delete(); |
|
48 | 2 | return $content; |
|
49 | } else { |
||
50 | 20 | return parent::getContents(); |
|
51 | } |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Get a stream for the given node |
||
56 | * |
||
57 | * @param string $mode |
||
58 | * |
||
59 | * @return resource |
||
60 | */ |
||
61 | 2 | public function getStream($mode = 'c+') |
|
65 | } |
||
66 |