| Server IP : 87.229.120.60 / Your IP : 216.73.216.86 Web Server : Apache System : Linux outside 5.4.8_Algonet_ZeroMAC_0.9.4.8 #6 SMP Mon Feb 3 20:36:07 CET 2020 x86_64 User : server ( 1002) PHP Version : 8.3.20 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,curl_multi_exec,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/faktorteam/www/wp-content/plugins/wp-rocket/inc/Engine/Container/Inflector/ |
Upload File : |
<?php
namespace WP_Rocket\Engine\Container\Inflector;
use WP_Rocket\Engine\Container\ImmutableContainerAwareTrait;
use WP_Rocket\Engine\Container\Argument\ArgumentResolverInterface;
use WP_Rocket\Engine\Container\Argument\ArgumentResolverTrait;
class Inflector implements ArgumentResolverInterface
{
use ArgumentResolverTrait;
use ImmutableContainerAwareTrait;
/**
* @var array
*/
protected $methods = [];
/**
* @var array
*/
protected $properties = [];
/**
* Defines a method to be invoked on the subject object.
*
* @param string $name
* @param array $args
* @return $this
*/
public function invokeMethod($name, array $args)
{
$this->methods[$name] = $args;
return $this;
}
/**
* Defines multiple methods to be invoked on the subject object.
*
* @param array $methods
* @return $this
*/
public function invokeMethods(array $methods)
{
foreach ($methods as $name => $args) {
$this->invokeMethod($name, $args);
}
return $this;
}
/**
* Defines a property to be set on the subject object.
*
* @param string $property
* @param mixed $value
* @return $this
*/
public function setProperty($property, $value)
{
$this->properties[$property] = $value;
return $this;
}
/**
* Defines multiple properties to be set on the subject object.
*
* @param array $properties
* @return $this
*/
public function setProperties(array $properties)
{
foreach ($properties as $property => $value) {
$this->setProperty($property, $value);
}
return $this;
}
/**
* Apply inflections to an object.
*
* @param object $object
* @return void
*/
public function inflect($object)
{
$properties = $this->resolveArguments(array_values($this->properties));
$properties = array_combine(array_keys($this->properties), $properties);
foreach ($properties as $property => $value) {
$object->{$property} = $value;
}
foreach ($this->methods as $method => $args) {
$args = $this->resolveArguments($args);
call_user_func_array([$object, $method], $args);
}
}
}