private static function instantiate($class, array $configs)
    {
        $reflection = new ReflectionClass($class);
        $constructor = $reflection->getConstructor();
        $arguments = array();

        foreach ($constructor->getParameters() as $param) {
            $name = $param->getName();
            if (isset($configs[$name])) {
                $arguments[] = $configs[$name];
                continue;
            }

            $arguments[] = null;
        }

        $broadcaster = $reflection->newInstanceArgs($arguments);

        if (!$broadcaster instanceof BroadcasterInterface) {
            throw new RuntimeException(sprintf(
                'Broadcaster "%s" should implement Borobudur\Broadcasting\Broadcaster\BroadcasterInterface',
                $class
            ));
        }

        return $broadcaster;
    }
private static function instantiate($class, array $configs)
    {
        $reflection = new ReflectionClass($class);
        $constructor = $reflection->getConstructor();
        $arguments = array();

        foreach ($constructor->getParameters() as $param) {
            $name = $param->getName();
            if (isset($configs[$name])) {
                $arguments[] = $configs[$name];
                continue;
            }

            $arguments[] = null;
        }

        $broadcaster = $reflection->newInstanceArgs($arguments);

        if (!$broadcaster instanceof BroadcasterInterface) {
            throw new RuntimeException(sprintf(
                'Broadcaster "%s" should implement Borobudur\Broadcasting\Broadcaster\BroadcasterInterface',
                $class
            ));
        }

        return $broadcaster;
    }
private static function instantiate ( $ class , array $ configs ) { $ reflection = new ReflectionClass ( $ class ) ; $ constructor = $ reflection -> getConstructor ( ) ; $ arguments = array ( ) ; foreach ( $ constructor -> getParameters ( ) as $ param ) { $ name = $ param -> getName ( ) ; if ( isset ( $ configs [ $ name ] ) ) { $ arguments [ ] = $ configs [ $ name ] ; continue ; } $ arguments [ ] = null ; } $ broadcaster = $ reflection -> newInstanceArgs ( $ arguments ) ; if ( ! $ broadcaster instanceof BroadcasterInterface ) { throw new RuntimeException ( sprintf ( 'Broadcaster "%s" should implement Borobudur\Broadcasting\Broadcaster\BroadcasterInterface' , $ class ) ) ; } return $ broadcaster ; }
Instantiate broadcaster.

@param string $class
@param array  $configs

@return BroadcasterInterface
Instantiate broadcaster .