Skip to content

Commit

Permalink
feat: allow to replace raw class for the original class invocations
Browse files Browse the repository at this point in the history
Closes #3
  • Loading branch information
whizark committed May 3, 2016
1 parent 6563cf3 commit e6bbbc1
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
29 changes: 27 additions & 2 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
*/
class Api
{
/**
* @var string The class name for the original CFS API invocation in a static context.
*/
protected static $rawClassName = 'cfs_api';

/**
* @var mixed[] The cache to store the original CFS cache.
*/
Expand Down Expand Up @@ -56,7 +61,27 @@ public function __construct(cfs_api $rawApi = null)
*/
public static function __callStatic($name, $arguments)
{
return forward_static_call_array(['cfs_api', $name], $arguments);
return forward_static_call_array([static::$rawClassName, $name], $arguments);
}

/**
* Gets the class name for the original CFS API invocation in a static context.
*
* @return string The class name.
*/
public static function getRawClassName()
{
return static::$rawClassName;
}

/**
* Sets the class name for the original CFS API invocation in a static context.
*
* @param string $className The class name.
*/
public static function setRawClassName($className)
{
static::$rawClassName = $className;
}

/**
Expand All @@ -69,7 +94,7 @@ public static function __callStatic($name, $arguments)
*/
public function __call($name, $arguments)
{
return call_user_func_array(['cfs_api', $name], $arguments);
return call_user_func_array([$this->rawApi, $name], $arguments);
}

/**
Expand Down
29 changes: 27 additions & 2 deletions src/FieldGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
*/
class FieldGroup
{
/**
* @var string The class name for the original CFS Field Group invocation in a static context.
*/
protected static $rawClassName = 'cfs_field_group';

/**
* @var mixed[] The cache to store the original CFS cache.
*/
Expand Down Expand Up @@ -56,7 +61,27 @@ public function __construct(cfs_field_group $rawFieldGroup = null)
*/
public static function __callStatic($name, $arguments)
{
return forward_static_call_array(['cfs_field_group', $name], $arguments);
return forward_static_call_array([static::$rawClassName, $name], $arguments);
}

/**
* Gets the class name for the original CFS API invocation in a static context.
*
* @return string The class name.
*/
public static function getRawClassName()
{
return static::$rawClassName;
}

/**
* Sets the class name for the original CFS API invocation in a static context.
*
* @param string $className The class name.
*/
public static function setRawClassName($className)
{
static::$rawClassName = $className;
}

/**
Expand All @@ -69,7 +94,7 @@ public static function __callStatic($name, $arguments)
*/
public function __call($name, $arguments)
{
return call_user_func_array(['cfs_field_group', $name], $arguments);
return call_user_func_array([$this->rawFieldGroup, $name], $arguments);
}

/**
Expand Down

0 comments on commit e6bbbc1

Please sign in to comment.