Uname: Linux webm012.cluster130.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 8.0.30 [ PHP INFO ] PHP os: Linux
Server Ip: 145.239.37.162
Your Ip: 216.73.216.190
User: dreampi (1009562) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : TestParam.php
<?php

declare(strict_types=1);

namespace Core\TestCase;

use apimatic\jsonmapper\JsonMapperException;
use Closure;
use Core\Client;
use Core\Types\Sdk\CoreFileWrapper;
use Core\Utils\CoreHelper;
use Exception;

class TestParam
{
    /**
     * Returns a typeGroup type TestParam.
     *
     * @param string $json          Json value to be mapped by the typeGroup
     * @param string $typeGroup     Group of types in string format i.e. oneOf(...), anyOf(...)
     * @param array  $deserializers Methods required for the de-serialization of specific types in
     *                              in the provided typeGroup, should be an array in the format:
     *                              ['path/to/method returnType', ...]. Default: []
     * @return mixed Returns the mapped value from json
     * @throws JsonMapperException
     */
    public static function typeGroup(string $json, string $typeGroup, array $deserializers = [])
    {
        return Client::getJsonHelper()->mapTypes(CoreHelper::deserialize($json, false), $typeGroup, $deserializers);
    }

    /**
     * Returns an object type TestParam.
     *
     * @param string       $json     Json value to be mapped by the class
     * @param string|null $classname Name of the class inclusive of its namespace,
     *                               Default: object
     * @param int         $dimension Greater than 0 if trying to map an array of
     *                               class with some dimensions, Default: 0
     * @return mixed Returns the mapped value from json
     * @throws Exception
     */
    public static function object(string $json, ?string $classname = null, int $dimension = 0)
    {
        if (is_null($classname)) {
            return CoreHelper::deserialize($json);
        }
        return Client::getJsonHelper()->mapClass(CoreHelper::deserialize($json, false), $classname, $dimension);
    }

    /**
     * Returns a custom TestParam.
     *
     * @param string   $json     Json value to be deserialized using custom callback
     * @param callable $callback Callback use to deserialize the given value
     * @return mixed Returns the result from the callback
     */
    public static function custom(string $json, callable $callback)
    {
        return Closure::fromCallable($callback)(CoreHelper::deserialize($json, false));
    }

    /**
     * Returns a file type TestParam.
     *
     * @param string $url URL of the file to download
     */
    public static function file(string $url)
    {
        $realPath = CoreFileWrapper::getDownloadedRealFilePath($url);
        return self::localFile($realPath);
    }

    /**
     * Returns a localFile TestParam.
     *
     * @param string $realPath Local path to the file
     */
    public static function localFile(string $realPath)
    {
        return Client::getConverter()->createFileWrapper($realPath, null, '');
    }
}
© 2026 GrazzMean-Shell