Пример #1
0
 public function testEmptyFileWillReturnEmptyArrayForGetContents()
 {
     $fileSystem = $this->getFilesystem();
     $file = new FileNode($fileSystem, 'not/exists');
     $fileSystem->shouldReceive('has')->with('not/exists')->andReturn(false);
     static::assertEquals([], $file->getContents());
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function getContents()
 {
     if ($this->exists() && !in_array($this->getCompression(), [CompressionFactory::TYPE_NONE, CompressionFactory::TYPE_UNKNOWN])) {
         /** @var CompressionFactory $factory */
         $factory = $this->getBuilder()->build(CompressionFactory::class);
         $compressor = $factory->getDeCompressor($this->getCompression());
         $uncompressed = $compressor->decompress($this);
         $content = $uncompressed->getContents();
         $uncompressed->delete();
         return $content;
     } else {
         return parent::getContents();
     }
 }