| 1 |
<?php |
| 2 |
|
| 3 |
namespace ipl\Web\Common; |
| 4 |
|
| 5 |
use LogicException; |
| 6 |
|
| 7 |
/** @deprecated Use your own implementation instead */ |
| 8 |
abstract class BaseOrderedListItem extends BaseListItem |
| 9 |
{ |
| 10 |
/** @var ?int This element's position */ |
| 11 |
protected $order; |
| 12 |
|
| 13 |
/** |
| 14 |
* Set this element's position |
| 15 |
* |
| 16 |
* @param int $order |
| 17 |
* |
| 18 |
* @return $this |
| 19 |
*/ |
| 20 |
public function setOrder(int $order): self |
| 21 |
{ |
| 22 |
$this->order = $order; |
| 23 |
|
| 24 |
return $this; |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Get this element's position |
| 29 |
* |
| 30 |
* @return int |
| 31 |
* @throws LogicException When calling this method without setting the `order` property |
| 32 |
*/ |
| 33 |
public function getOrder(): int |
| 34 |
{ |
| 35 |
if ($this->order === null) { |
| 36 |
throw new LogicException( |
| 37 |
'You are accessing an unset property. Please make sure to set it beforehand.' |
| 38 |
); |
| 39 |
} |
| 40 |
|
| 41 |
return $this->order; |
| 42 |
} |
| 43 |
} |