FBMock_Config::get PHP Method

get() final public static method

final public static get ( )
    public static final function get()
    {
        if (!self::$config) {
            $custom_config_path = __DIR__ . '/CustomConfig.php';
            if (file_exists($custom_config_path)) {
                require_once $custom_config_path;
                self::$config = new FBMock_CustomConfig();
            } else {
                self::$config = new FBMock_Config();
            }
        }
        return self::$config;
    }

Usage Example

 public final function generateCode(ReflectionClass $class, $test_double_class_name, array $interfaces = array(), array $traits = array(), $method_checker = null)
 {
     FBMock_Utils::assertString($test_double_class_name);
     if ($class->isFinal() && !$this->canOverrideFinals()) {
         throw new FBMock_TestDoubleException("Cannot mock final class %s", $class->getName());
     }
     $code = $this->getMockClassHeader($class, $test_double_class_name, $interfaces, $traits) . "\n";
     $method_sources = array();
     foreach ($class->getMethods() as $method) {
         $method_checker && $method_checker($class, $method);
         if ($method->isFinal() && !$this->canOverrideFinals()) {
             continue;
         }
         // #1137433
         if (!$class->isInterface()) {
             $method = new ReflectionMethod($class->getName(), $method->getName());
         }
         $test_double_method_generator = FBMock_Config::get()->getMethodGenerator();
         $method_source = $test_double_method_generator->generateCode($method);
         if ($method_source) {
             $method_sources[] = $method_source;
         }
     }
     $code .= implode("\n\n", $method_sources);
     $code .= "\n}";
     // close class
     return $code;
 }
All Usage Examples Of FBMock_Config::get