summaryrefslogtreecommitdiffstats
path: root/library/Icingadb/Common/BaseOrderedListItem.php
blob: bf0f2b2a72beadc26e2f9ff569b36156aa9dcf71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */

namespace Icinga\Module\Icingadb\Common;

abstract class BaseOrderedListItem extends BaseListItem
{
    /** @var int This element's position */
    protected $order;

    /**
     * Set this element's position
     *
     * @param int $order
     *
     * @return $this
     */
    public function setOrder(int $order): self
    {
        $this->order = $order;

        return $this;
    }

    /**
     * Get this element's position
     *
     * @return int
     */
    public function getOrder()
    {
        if ($this->order === null) {
            throw new \LogicException(
                'You are accessing an unset property. Please make sure to set it beforehand.'
            );
        }

        return $this->order;
    }
}