"Fossies" - the Fresh Open Source Software Archive

Member "contao-4.4.48/core-bundle/src/Framework/Adapter.php" (2 Apr 2020, 892 Bytes) of package /linux/www/contao-4.4.48.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Adapter.php" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 4.8.8_vs_4.9.0.

    1 <?php
    2 
    3 /*
    4  * This file is part of Contao.
    5  *
    6  * (c) Leo Feyer
    7  *
    8  * @license LGPL-3.0-or-later
    9  */
   10 
   11 namespace Contao\CoreBundle\Framework;
   12 
   13 /**
   14  * Wraps unmockable classes and delegates the method calls.
   15  *
   16  * @author Yanick Witschi <https://github.com/toflar>
   17  *
   18  * @internal Do not instantiate this class in your code; use ContaoFramework::getAdapter() instead
   19  */
   20 class Adapter
   21 {
   22     /**
   23      * @var string
   24      */
   25     private $class;
   26 
   27     /**
   28      * Constructor.
   29      *
   30      * @param string $class
   31      */
   32     public function __construct($class)
   33     {
   34         $this->class = $class;
   35     }
   36 
   37     /**
   38      * Calls a method of the adapted class.
   39      *
   40      * @param string $name
   41      * @param array  $arguments
   42      *
   43      * @return mixed
   44      */
   45     public function __call($name, array $arguments = [])
   46     {
   47         return \call_user_func_array([$this->class, $name], $arguments);
   48     }
   49 }