for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Triadev\Leopard\Model;
use Illuminate\Support\Collection;
class SearchResult
{
/** @var int */
private $took;
/** @var bool */
private $timedOut;
/** @var array */
private $shards;
/** @var Collection */
private $hits;
private $totalHits;
/** @var float */
private $maxScore;
/** @var array|null */
private $aggregation;
/**
* SearchResult constructor.
* @param array $result
*/
public function __construct(array $result)
$this->took = (int)array_get($result, 'took');
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
$a = "a"; $ab = "ab"; $abc = "abc";
will produce issues in the first and second line, while this second example
will produce no issues.
$this->timedOut = (bool)array_get($result, 'timed_out');
$this->shards = (array)array_get($result, '_shards');
$this->hits = new Collection(array_get($result, 'hits.hits'));
$this->totalHits = (int)array_get($result, 'hits.total');
$this->maxScore = (float)array_get($result, 'hits.max_score');
$this->aggregation = array_get($result, 'aggregations', null);
}
* @return int
public function getTook(): int
return $this->took;
* @return bool
public function isTimedOut(): bool
return $this->timedOut;
* @return array
public function getShards(): array
return $this->shards;
* @return Collection
public function getHits(): Collection
return $this->hits;
* @param Collection $hits
public function setHits(Collection $hits)
$this->hits = $hits;
public function getTotalHits(): int
return $this->totalHits;
* @return float
public function getMaxScore(): float
return $this->maxScore;
* @return array|null
public function getAggregation(): ?array
return $this->aggregation;
This check marks files that end in a newline character, i.e. an empy line.