<?php

namespace Fab\Controller;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * Controller
 *
 * @package    Fab
 * @subpackage Fab/Controller
 */
class Controller {

    // Load plugin traits.
    use \Fab\Plugin\Helper\Singleton;
    use \Fab\Helper\GetterSetter;

    /**
     * Controller constructor
     *
     * @return void
     */
    public function __construct() {}

    /**
     * Magic method for static methods
     * - This method will be used to implement Just In Time (JIT) loading.
     *
     * @param   string $method     Method name.
     * @param   array  $arguments  Arguments passed to the method.
     * @return  mixed
     */
    public static function __callStatic( $method, $arguments ) {
        // Context aware static method for just in time (JIT) loading.
        if ( strpos( $method, 'jit_' ) === 0 ) {
            $method = substr( $method, 4 );
            $class  = get_called_class()::get_instance();
            return $class->{$method}( ...$arguments );
        }
    }
}
