for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/**
* Infrastructure Related Agent
* @author Max Demian <[email protected]>
*/
namespace Ticaje\FileManager\Infrastructure\Driver\Traits;
use Iterator;
use Ticaje\FileManager\Infrastructure\Driver\Reader\Interfaces\FileInterface as ReferencedSignature;
* Trait FileInterface
* @package Ticaje\FileManager\Infrastructure\Driver\Traits
* Classes using this trait must implement interface FileInterface
trait FileInterface
{
/** @var Iterator|array $header */
private $header = [];
* @inheritDoc
public function getHeader()
return !empty($this->header) ? $this->header : (function () {
$this->setHeader();
return $this->header;
})();
}
private function setHeader(): ReferencedSignature
if ($this->hasHeader()) {
$this->header = $this->isContentIterator() ? (function () {
return $this->content->current();
})() : array_shift($this->getContent());
$this->getContent()
Iterator
array
$array
array_shift()
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
})() : array_shift(/** @scrutinizer ignore-type */ $this->getContent());
return $this;
return $this
Ticaje\FileManager\Infra...er\Traits\FileInterface
Ticaje\FileManager\Infra...nterfaces\FileInterface
public function hasHeader(): bool
return $this->hasHeader;
private function isContentIterator()
return $this->content instanceof Iterator;
public function getContent(): Iterator
return $this->content;