Campaigns.php
2 years ago
Cities.php
2 years ago
Countries.php
2 years ago
Device_Browsers.php
2 years ago
Device_OSS.php
2 years ago
Device_Types.php
2 years ago
Filter.php
2 years ago
Pages.php
2 years ago
Referrers.php
2 years ago
Rows.php
2 years ago
Rows.php
35 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP\Rows; |
| 4 | |
| 5 | use IAWP\Date_Range\Date_Range; |
| 6 | use IAWP\Sort_Configuration; |
| 7 | use IAWPSCOPED\Illuminate\Database\Query\Builder; |
| 8 | /** @internal */ |
| 9 | abstract class Rows |
| 10 | { |
| 11 | protected $date_range; |
| 12 | protected $number_of_rows; |
| 13 | /** @var Filter[] */ |
| 14 | protected $filters; |
| 15 | protected $sort_configuration; |
| 16 | private $rows = null; |
| 17 | public function __construct(Date_Range $date_range, ?int $number_of_rows = null, ?array $filters = null, ?Sort_Configuration $sort_configuration = null) |
| 18 | { |
| 19 | $this->date_range = $date_range; |
| 20 | $this->number_of_rows = $number_of_rows; |
| 21 | $this->filters = $filters ?? []; |
| 22 | $this->sort_configuration = $sort_configuration ?? new Sort_Configuration(); |
| 23 | } |
| 24 | protected abstract function fetch_rows() : array; |
| 25 | public abstract function attach_filters(Builder $query) : void; |
| 26 | public function rows() |
| 27 | { |
| 28 | if (\is_array($this->rows)) { |
| 29 | return $this->rows; |
| 30 | } |
| 31 | $this->rows = $this->fetch_rows(); |
| 32 | return $this->rows; |
| 33 | } |
| 34 | } |
| 35 |