PHP Classes

File: src/Result/Assoc.php

Recommend this page to a friend!
  Classes of Scott Arciszewski   iaso PHP JSON Parser Library   src/Result/Assoc.php   Download  
File: src/Result/Assoc.php
Role: Class source
Content type: text/plain
Description: Class source
Class: iaso PHP JSON Parser Library
Parse JSON strings immune to hash-DoS attacks
Author: By
Last change:
Date: 2 years ago
Size: 645 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);
namespace
ParagonIE\Iaso\Result;

use
ParagonIE\Iaso\ResultSet;

/**
 * Class Assoc
 * @package ParagonIE\Iaso\Result
 */
class Assoc extends ResultSet
{
   
/**
     * @param string $key
     * @return string
     * @throws \TypeError
     */
   
protected function getIndex($key = ''): string
   
{
        if (!\
is_string($key)) {
            throw new \
TypeError('Key must be a string, ' . \gettype($key) . ' given.');
        }
        return
$this->getHash($key);
    }

   
/**
     * @param array $array
     */
   
protected function sort(array &$array)
    {
        \
ksort($array, SORT_STRING);
    }
}