Return value of array's item by key or index

@since   1.1
@param   array|\Pabana\Type\ArrayType $arrayOrObjectVar Array or Object
@param   int $priority Merge priority
@return  void
166629
public function merge($arrayOrObjectVar, $priority = self::MERGE_ARGUMENT)
    {
        if (is_object($arrayOrObjectVar)) {
            $arrayVar = $arrayOrObjectVar->toArray();
        } else {
            $arrayVar = $arrayOrObjectVar;
        }
        if ($priority == 1) {
            $this->arrayVar = array_merge($this->arrayVar, $arrayOrObjectVar);
        } else if ($priority == 2) {
            $this->arrayVar = array_merge($arrayOrObjectVar, $this->arrayVar);
        } else if ($priority == 3) {
            $arrayMerge = array();
            $arrayIndex = 0;
            foreach ($this->arrayVar as $value) {
                $arrayMerge[$arrayIndex] = $value;
                $arrayIndex++;
            }
            foreach ($arrayVar as $value) {
                $arrayMerge[$arrayIndex] = $value;
                $arrayIndex++;
            }
            $this->arrayVar = $arrayMerge;
        }
    }
763232
public static void atIndex( final int[] array, int index, int value ) {
        final int i = calculateIndex( array, index );

        array[ i ] = value;
    }
61123
public static function has($subjectArrayOrObject, $dotNotationKeys)
    {
        if (empty($subjectArrayOrObject) || !$dotNotationKeys) {
            return false;
        }

        $defaultValue = 'DotArray::has->doesNotExist';

        $data = self::walkArrayOrObject($subjectArrayOrObject, $dotNotationKeys, $defaultValue);

        return $defaultValue !== $data;
    }
883740
private function sortByPriority($a, $b)
    {
        $a = $a['_priority'];
        $b = $b['_priority'];

        if ($a == $b) {
            return 0;
        }

        return ($a < $b) ? -1 : 1;
    }
502780
public function writeVariableValue(Variable $variable, $valueType = self::RW_VALUE)
    {
        switch ($valueType) {
            case self::RW_DEFAULTVALUE:
                $getterToCall = 'getDefaultValue';
                break;
                
            case self::RW_CORRECTRESPONSE:
                $getterToCall = 'getCorrectResponse';
                break;
                
            default:
                $getterToCall = 'getValue';
        }
        
        try {
            $value = call_user_func(array($variable, $getterToCall));
            $cardinality = $variable->getCardinality();
            $baseType = $variable->getBaseType();

            if (is_null($value) === true) {
                $this->writeBoolean(true);

                return;
            }

            // Non-null value.
            $this->writeBoolean(false);

            if ($cardinality === Cardinality::RECORD) {
                // is-scalar
                $this->writeBoolean(false);

                // count
                $this->writeShort(count($value));

                // content
                foreach ($value as $k => $v) {
                    $this->writeRecordField(array($k, $v), is_null($v));
                }
            } else {
                $toCall = 'write' . ucfirst(BaseType::getNameByConstant($baseType));

                if ($cardinality === Cardinality::SINGLE) {
                    // is-scalar
                    $this->writeBoolean(true);

                    // content
                    $this->$toCall(($value instanceof QtiScalar) ? $value->getValue() : $value);
                } else {
                    // is-scalar
                    $this->writeBoolean(false);

                    // count
                    $this->writeShort(count($value));

                    // MULTIPLE or ORDERED
                    foreach ($value as $v) {
                        if (is_null($v) === false) {
                            $this->writeBoolean(false);
                            $this->$toCall(($v instanceof QtiScalar) ? $v->getValue() : $v);
                        } else {
                            $this->writeBoolean(true);
                        }
                    }
                }
            }
        } catch (BinaryStreamAccessException $e) {
            $msg = "An error occured while writing a Variable value.";
            throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::VARIABLE, $e);
        }
    }
954874
public static function Srv(int $priority, int $weight, int $port, string $target)
    {
        $rdata = new SRV();
        $rdata->setPriority($priority);
        $rdata->setWeight($weight);
        $rdata->setPort($port);
        $rdata->setTarget($target);

        return $rdata;
    }
1043268
public function enqueue( KObjectHandlable $object, $priority)
    {
        $result = false;

        if($handle = $object->getHandle())
        {
            $this->__object_list->offsetSet($handle, $object);

            $this->__priority_list->offsetSet($handle, $priority);
            $this->__priority_list->asort();

            if($object instanceof KObjectInterface) {
                $this->__identifier_list[$handle] = $object->getIdentifier();
            }

            $result = true;
        }

        return $result;
    }
1171712
public function push($value, int $priority)
    {
        $this->checkCapacity();

        // Add new leaf, then sift up to maintain heap,
        $this->heap[] = new PriorityNode($value, $priority, $this->stamp++);
        $this->siftUp(count($this->heap) - 1);
    }
801480
public function setRawProperty( $rawName, $value,
                                    $priority = self::PRIORITY_NORMAL )
    {
        if ( is_array( $value ) )
        {
            $value = (object) $value;
        }

        if ( is_object( $value ) )
        {
            if ( isset( $value->priority ) )
            {
                $priority = $value->priority;
            }

            if ( isset( $value->value ) )
            {
                $value = $value->value;
            }
            else
            {
                $value = null;
            }
        }

        $rawName    = (string) $rawName;
        $value      = (string) $value;
        $priority   = ( (string) $priority ) ?: self::PRIORITY_NORMAL;

        if ( '' === $value )
        {
            return $this->removeRawProperty( $rawName );
        }

        $this->properties[$rawName] = array(
            'name'      => $rawName,
            'value'     => $value,
            'priority'  => $priority,
        );

        return $this;
    }
1339454
public void addSort(Object object, int sort, int priority) {
        key.addPrimitiveValue(String.format(SORT_LABEL, priority), object, sort, priority);
    }
1094465
final function GetVar($qry, $row_no = 0, $offset = 0)
    {
        if ($this->lock_sel_data) {
            return array();
        }
        if ($this->Query($qry)) {
            $this->result = $this->Fetch($this->query_result, $row_no, $offset);
            $this->SetDebugDump($offset);

            return $this->result[0][0];
        }
        return array();
    }
229794
public function enqueue(AnObjectHandlable $object, $priority)
    {
        $this->getRepositoryEntities($object->getRepository())->insert($object);

        return parent::enqueue($object, $priority);
    }
1238244
public function set($key, $value, $priority = 0)
    {
        $key = $this->getScalarKey($key);

        $this->list[$key] = new \stdclass();
        $this->list[$key]->value = $value;
        $this->list[$key]->priority = (int) $priority;
        $this->list[$key]->sequence = $this->lastSequence++;

        return $this->list[$key];
    }
1277586
protected function sortActionsByPriority(array $a, array $b)
    {
        $a = isset($a['priority']) ? $a['priority'] : 0;
        $b = isset($b['priority']) ? $b['priority'] : 0;

        if ($a === $b) {
            return 0;
        }
        return ($a < $b) ? (-1) : 1;
    }
160059
public function setPriority(ObjectHandlable $object, $priority)
    {
        if($handle = $object->getHandle())
        {
            if($this->__priority_list->offsetExists($handle))
            {
                $this->__priority_list->offsetSet($handle, $priority);
                $this->__priority_list->asort();
            }
        }

        return $this;
    }
254248
public function get_data($priority = null)
    {
        if ($priority === null) {
            return $this->data;
        }

        if (isset($this->data[ $priority ])) {
            return $this->data[ $priority ];
        }

        return [];
    }
910734
public function addItem(string $name, $item, int $priority = 50): self
    {
        if ($this->has($name)) {
            throw new DuplicateKeyException('Item with name '.$name.' already defined');
        }

        $this->items[$priority][$name] = $item;
        return $this;
    }