src/Cache/Cache.php
public static function fromJson($json)
    {
        $data = json_decode($json, true);

        if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
            throw new \InvalidArgumentException(sprintf(
                'Value needs to be a valid JSON string, got "%s", error: "%s".',
                \is_object($json) ? \get_class($json) : \gettype($json),
                json_last_error_msg()
            ));
        }

        $requiredKeys = [
            'php',
            'version',
            'indent',
            'lineEnding',
            'rules',
            'hashes',
        ];

        $missingKeys = array_diff_key(array_flip($requiredKeys), $data);

        if (\count($missingKeys)) {
            throw new \InvalidArgumentException(sprintf(
                'JSON data is missing keys "%s"',
                implode('", "', $missingKeys)
            ));
        }

        $signature = new Signature(
            $data['php'],
            $data['version'],
            $data['indent'],
            $data['lineEnding'],
            $data['rules']
        );

        $cache = new self($signature);

        $cache->hashes = $data['hashes'];

        return $cache;
    }
public static function fromJson($json)
    {
        $data = json_decode($json, true);

        if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
            throw new \InvalidArgumentException(sprintf(
                'Value needs to be a valid JSON string, got "%s", error: "%s".',
                \is_object($json) ? \get_class($json) : \gettype($json),
                json_last_error_msg()
            ));
        }

        $requiredKeys = [
            'php',
            'version',
            'indent',
            'lineEnding',
            'rules',
            'hashes',
        ];

        $missingKeys = array_diff_key(array_flip($requiredKeys), $data);

        if (\count($missingKeys)) {
            throw new \InvalidArgumentException(sprintf(
                'JSON data is missing keys "%s"',
                implode('", "', $missingKeys)
            ));
        }

        $signature = new Signature(
            $data['php'],
            $data['version'],
            $data['indent'],
            $data['lineEnding'],
            $data['rules']
        );

        $cache = new self($signature);

        $cache->hashes = $data['hashes'];

        return $cache;
    }
public static function fromJson ( $ json ) { $ data = json_decode ( $ json , true ) ; if ( null === $ data && JSON_ERROR_NONE !== json_last_error ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Value needs to be a valid JSON string, got "%s", error: "%s".' , \ is_object ( $ json ) ? \ get_class ( $ json ) : \ gettype ( $ json ) , json_last_error_msg ( ) ) ) ; } $ requiredKeys = [ 'php' , 'version' , 'indent' , 'lineEnding' , 'rules' , 'hashes' , ] ; $ missingKeys = array_diff_key ( array_flip ( $ requiredKeys ) , $ data ) ; if ( \ count ( $ missingKeys ) ) { throw new \ InvalidArgumentException ( sprintf ( 'JSON data is missing keys "%s"' , implode ( '", "' , $ missingKeys ) ) ) ; } $ signature = new Signature ( $ data [ 'php' ] , $ data [ 'version' ] , $ data [ 'indent' ] , $ data [ 'lineEnding' ] , $ data [ 'rules' ] ) ; $ cache = new self ( $ signature ) ; $ cache -> hashes = $ data [ 'hashes' ] ; return $ cache ; }
@param string $json

@throws \InvalidArgumentException

@return Cache
@param string $json