Skip to content

Instantly share code, notes, and snippets.

@DarkGhostHunter
Last active January 17, 2020 22:59
Show Gist options
  • Save DarkGhostHunter/c3d858fcab3c5019c7c599105ca02485 to your computer and use it in GitHub Desktop.
Save DarkGhostHunter/c3d858fcab3c5019c7c599105ca02485 to your computer and use it in GitHub Desktop.
Infinite tapping
<?php
namespace App\Helpers;
use Illuminate\Support\Str;
use Illuminate\Support\HigherOrderTapProxy;
class InfiniteHigherOrderTapProxy extends HigherOrderTapProxy
{
/**
* Dynamically pass method calls to the target.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
if (Str::endsWith('AndUntap', $method)) {
return $this->target->{substr($method, 0, -8)}(...$parameters);
}
parent::__call($method, $parameters);
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment