| 1 | <?php |
||
| 9 | class LocalFile extends FileNode implements LocalFileNodeInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var string - CompressionType:: |
||
| 13 | */ |
||
| 14 | protected $compression; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var string|null |
||
| 18 | */ |
||
| 19 | protected $encoding; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param string $path |
||
| 23 | */ |
||
| 24 | 89 | public function __construct($path) |
|
| 31 | |||
| 32 | /** |
||
| 33 | * @return string |
||
| 34 | */ |
||
| 35 | 10 | public function getEncoding() |
|
| 39 | |||
| 40 | /** |
||
| 41 | * @param string $encoding |
||
| 42 | * |
||
| 43 | * @return $this |
||
| 44 | */ |
||
| 45 | 10 | public function setEncoding($encoding) |
|
| 51 | |||
| 52 | /** |
||
| 53 | * {@inheritdoc} |
||
| 54 | */ |
||
| 55 | 16 | public function getContents() |
|
| 56 | { |
||
| 57 | 16 | if ($this->exists() && |
|
| 58 | 16 | $this->getCompression() != CompressionType::NONE |
|
| 59 | ) { |
||
| 60 | $uncompressed = $this->decompress(); |
||
|
|
|||
| 61 | $content = $uncompressed->getContents(); |
||
| 62 | $uncompressed->delete(); |
||
| 63 | return $content; |
||
| 64 | } else { |
||
| 65 | 16 | return parent::getContents(); |
|
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @return string - see CompressionType:: |
||
| 71 | */ |
||
| 72 | 25 | public function getCompression() |
|
| 76 | |||
| 77 | /** |
||
| 78 | * @param string $compression - @see CompressionType:: |
||
| 79 | * |
||
| 80 | * @return $this |
||
| 81 | */ |
||
| 82 | 16 | public function setCompression($compression) |
|
| 88 | } |
||
| 89 |
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: