Register the port, resolve if class name is provided
and return the resolved instance.

@param \SuperV\Platform\Domains\Port\Port $port
@return mixed
190408
public function register($port)
    {
        if (is_string($port)) {
            $port = resolve($port);
        }

        $this->ports->push($port);

        return $port;
    }
159318
private function setPort($port)
    {
        $port = (int) $port;

        if ($port < 0 || $port > 65535) {
            throw new \InvalidArgumentException('Port must be between 1 and 65535!');
        }

        if (empty($port)) {
            $port = null;
        }

        $this->port = $port;

        return $this;
    }
941907
public function register(Container $container)
    {
        $this->container = $container;

        // Register the PHP view loader if configuration says so
        if (strtolower($container["config.service"]["view.loader"]) === "php") {
            $container->register(new PHPLoaderProvider);
        }

        // Define view class loader
        $container["loadView.service"] = $container->protect(
            function (string $view, bool $useLayout = true) use ($container) {
                $cacheName = "loadView.service-{$view}" . ($useLayout ? "1" : "0");
                if (isset($container[$cacheName]) && isset($container["view.skipCache"]) === false) {
                    return $container[$cacheName];
                }

                $class = $container["view.className"] ?? $this->getViewClass($view);
                $view = new $class(
                    $container["config.service"],
                    $container["tplLoader.service"],
                    $container["response.service"]
                );

                if (method_exists($view, "init")) {
                    $args = func_get_args();
                    $args = array_slice($args, 2);
                    $view->init(...$args);
                }

                if ($useLayout && ($layoutName = $container["config.service"]["view.defaultLayout"]) !== "") {
                    $this->setLayout($layoutName, $view);
                }

                return $container[$cacheName] = $view;
            }
        );

        $container["loadTemplate.service"] = $container->protect(
            function (string $template, bool $useLayout = true) use ($container) {
                $cacheName = "loadTemplate.service-{$template}" . ($useLayout ? "1" : "0");
                if (isset($container[$cacheName])) {
                    return $container[$cacheName];
                }

                $container["view.skipCache"] = true;
                $container["view.className"] = \SlaxWeb\View\Base::class;
                $view = $container["loadView.service"]("", false);
                $view->template = $template;
                unset($container["view.skipCache"], $container["view.className"]);

                if ($useLayout && ($layoutName = $container["config.service"]["view.defaultLayout"]) !== "") {
                    $this->setLayout($layoutName, $view);
                }

                return $container[$cacheName] = $view;
            }
        );
    }
232841
public function resolve(Container $container, array $args = [])
    {
        if ($this->resolvedDefinition && $this->shared === true) {
            return $this->resolvedDefinition;
        }

        $definitionResolver = new DefinitionResolver($container);
        $this->resolvedDefinition = $definitionResolver->resolver($this->definition, $args);
        $this->resolved = true;

        return $this->resolvedDefinition;
    }
140001
protected static function filterPort($port)
    {
        if ($port !== null) {
            if (! is_integer($port)) {
                throw new InvalidArgumentException(sprintf(
                    'Invalid port provided; must be an integer or null argument; received %s',
                    (is_object($port) ? get_class($port) : gettype($port))
                ));
            }

            if ($port < 1 || $port > 65535) {
                throw new InvalidArgumentException(sprintf(
                    'Invalid port "%d" specified; must be a valid TCP/UDP port',
                    $port
                ));
            }

            if (in_array($port, static::$standardSchemes)) {
                $port = null;
            }
        }

        return $port;
    }
449356
protected function resolve($class)
    {
        if (isset($this->container)) {
            $instance = $this->container->make($class);

            $instance->setContainer($this->container);
        } else {
            $instance = new $class;
        }

        if (isset($this->command)) {
            $instance->setCommand($this->command);
        }

        return $instance;
    }
472511
public function createClient($host, $port)
    {
        return $this->connector->create($host, $port)->then(function (DuplexStreamInterface $stream) {
            return new Client($stream);
        });
    }
286335
public function registerFactory()
    {
        $this->container['view'] = function ($container) {
            // Next we need to grab the engine resolver instance that will be used by the
            // environment. The resolver will be used by an environment to get each of
            // the various engine implementations such as plain PHP or Blade engine.
            $resolver = $container['view.engine.resolver'];

            $view = new Factory($resolver, $container['view.finder'], $container['events']);

            // We will also set the container instance on this view environment since the
            // view composers may be classes registered in the container, which allows
            // for great testable, flexible composers for the application developer.
            $view->setContainer($container);

            $view->share('container', $container);

            return $view;
        };
    }
524232
public function setPort($port)
    {
        if (intval($port) <= 0) {
            throw new \InvalidArgumentException(sprintf('Invalid port: %d', $port));
        }

        $this->port = intval($port);

        return $this;
    }
99933
public function withPort($port)
    {
        if ($port === null) {
            return $this->_clone('port', null);
        }

        if ($port < 1 || $port > 65535) {
            throw new InvalidArgumentException('Invalid port specified');
        }

        return $this->_clone('port', (int)$port);
    }
787274
function setPort($port)
    {
        if ($port !== null) {
            if (empty($port) && $port !== 0)
                $port = null;
            elseif ($port < 1 || $port > 65535)
                throw new \InvalidArgumentException(sprintf(
                    'Invalid port "%d" specified; must be a valid TCP/UDP port',
                    $port
                ));
        }

        $this->port = $port;
        return $this;
    }
162582
public static function isValid($port)
    {
        $port_valid = false;

        if (is_int($port)) {
            $port_valid = self::portIsInValidRange($port);
        } elseif (is_null($port)) {
            $port_valid = true;
        }

        return $port_valid;
    }
1146648
protected function resolveOnce($class)
    {
        if (isset($this->instances[$class])) {
            return $this->instances[$class];
        }
        $this->instances[$class] = call_user_func($this->container, $class);

        return $this->instances[$class];
    }
1066607
public function register(Container $container)
    {
        /**
         * @param  Container $container A container instance.
         * @return LoggerConfig
         */
        $container['logger/config'] = function (Container $container) {
            $appConfig    = isset($container['config']) ? $container['config'] : [];
            $loggerConfig = isset($appConfig['logger']) ? $appConfig['logger'] : null;
            return new LoggerConfig($loggerConfig);
        };

        /**
         * @return FactoryInterface
         */
        $container['logger/processor/factory'] = function () {
            return new Factory([
                'map' => [
                    'memory-usage' => MemoryUsageProcessor::class,
                    'uid'          => UidProcessor::class
                ]
            ]);
        };

        /**
         * @param  Container $container A container instance.
         * @return StreamHandler|null
         */
        $container['logger/handler/stream'] = function (Container $container) {
            $loggerConfig  = $container['logger/config'];
            $handlerConfig = $loggerConfig['handlers.stream'];

            if ($handlerConfig['active'] !== true) {
                return null;
            }

            $level = $handlerConfig['level'] ?: $loggerConfig['level'];
            return new StreamHandler($handlerConfig['stream'], $level);
        };

        /**
         * @param  Container $container A container instance.
         * @return BrowserConsoleHandler|null
         */
        $container['logger/handler/browser-console'] = function (Container $container) {
            $loggerConfig  = $container['logger/config'];
            $handlerConfig = $loggerConfig['handlers.console'];

            if ($handlerConfig['active'] !== true) {
                return null;
            }

            $level = $handlerConfig['level'] ?: $loggerConfig['level'];
            return new BrowserConsoleHandler($level);
        };

        /**
         * @param  Container $container A container instance.
         * @return Container Collection of defined record handlers, in a service container.
         */
        $container['logger/handlers'] = function (Container $container) {
            $loggerConfig   = $container['logger/config'];
            $handlersConfig = $loggerConfig['handlers'];
            $handlerFactory = $container['logger/handler/factory'];

            $handlers = new Container();
            foreach ($handlersConfig as $handler) {
                $handlers[$handler['type']] = function () use ($handler, $handlerFactory) {
                    $type    = $handler['type'];
                    $handler = $handlerFactory->create($type);
                    return $handler;
                };
            }

            return $handlers;
        };

        /**
         * Fulfills the PSR-3 dependency with a Monolog logger.
         *
         * @param  Container $container A container instance.
         * @return LoggerInterface
         */
        $container['logger'] = function (Container $container) {
            $loggerConfig = $container['logger/config'];

            if ($loggerConfig['active'] !== true) {
                return new NullLogger();
            }

            $logger = new Logger($loggerConfig['channel']);

            $memProcessor = new MemoryUsageProcessor();
            $logger->pushProcessor($memProcessor);

            $uidProcessor = new UidProcessor();
            $logger->pushProcessor($uidProcessor);

            $consoleHandler = $container['logger/handler/browser-console'];
            if ($consoleHandler) {
                $logger->pushHandler($consoleHandler);
            }

            $streamHandler = $container['logger/handler/stream'];
            if ($streamHandler) {
                $logger->pushHandler($streamHandler);
            }

            return $logger;
        };
    }
1184530
public function listen($port, $host = '0.0.0.0')
    {
        $this->port = $port;
        $this->host = $host;
        
        return $this;
    }
588058
protected function filterPort($port)
    {
        if (is_null($port) || (is_integer($port) && ($port >= 1 && $port <= 65535))) {
            return $port;
        }

        throw new InvalidArgumentException('Uri port must be null or an integer between 1 and 65535 (inclusive)');
    }
629304
public function setAccountingPort($port)
    {
        if ((intval($port) > 0) && (intval($port) < 65536))
        {
            $this->accountingPort = intval($port);
        }

        return $this;
    }