Prado\Collections\TPriorityList::removeAtIndexInPriority PHP Метод

removeAtIndexInPriority() публичный Метод

Removes the item at a specific index within a priority. Override and call this method to insert your own functionality.
public removeAtIndexInPriority ( $index, $priority = null ) : mixed
Результат mixed the removed item.
    public function removeAtIndexInPriority($index, $priority = null)
    {
        if ($this->getReadOnly()) {
            throw new TInvalidOperationException('list_readonly', get_class($this));
        }
        if ($priority === null) {
            $priority = $this->getDefaultPriority();
        }
        $priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
        if (!isset($this->_d[$priority]) || $index < 0 || $index >= count($this->_d[$priority])) {
            throw new TInvalidDataValueException('list_item_inexistent');
        }
        // $value is an array of elements removed, only one
        $value = array_splice($this->_d[$priority], $index, 1);
        $value = $value[0];
        if (!count($this->_d[$priority])) {
            unset($this->_d[$priority]);
        }
        $this->_c--;
        $this->_fd = null;
        return $value;
    }

Usage Example

Пример #1
0
 public function testCanNotRemoveAtIndexInPriorityWhenReadOnlyTList()
 {
     $plist = new TPriorityList($this->plist, true);
     try {
         $plist->removeAtIndexInPriority(0);
         self::fail('An expected TInvalidOperationException was not raised');
     } catch (TInvalidOperationException $e) {
     }
 }