private function build(string $type)
    {
        if (!in_array($type, ['public', 'local'])) {
            throw new \InvalidArgumentException('type accepts public or local');
        }
        if (!$this->called) {
            $url = $type === 'public' ? $this->config->env['public'] : $this->config->env['local'];
            $url = rtrim($url, '/');
            Util::clearDirectory($this->config->path('cache'));
            $articles        = ArticleGenerator::getArticles($this->config->path('article'), $url);
            $paths = $this->config->paths;
            $articles->each(function ($article) use ($paths) {
                $article->createCache("{$paths['cache']}/article");
            });
            $this->generator = new SiteGenerator($this->config, $articles);
            $this->called    = true;
        }
        Util::clearDirectory($this->config->path($type), true);
        $this->generator->generate($type);
    }
private function build(string $type)
    {
        if (!in_array($type, ['public', 'local'])) {
            throw new \InvalidArgumentException('type accepts public or local');
        }
        if (!$this->called) {
            $url = $type === 'public' ? $this->config->env['public'] : $this->config->env['local'];
            $url = rtrim($url, '/');
            Util::clearDirectory($this->config->path('cache'));
            $articles        = ArticleGenerator::getArticles($this->config->path('article'), $url);
            $paths = $this->config->paths;
            $articles->each(function ($article) use ($paths) {
                $article->createCache("{$paths['cache']}/article");
            });
            $this->generator = new SiteGenerator($this->config, $articles);
            $this->called    = true;
        }
        Util::clearDirectory($this->config->path($type), true);
        $this->generator->generate($type);
    }
private function build ( string $ type ) { if ( ! in_array ( $ type , [ 'public' , 'local' ] ) ) { throw new \ InvalidArgumentException ( 'type accepts public or local' ) ; } if ( ! $ this -> called ) { $ url = $ type === 'public' ? $ this -> config -> env [ 'public' ] : $ this -> config -> env [ 'local' ] ; $ url = rtrim ( $ url , '/' ) ; Util :: clearDirectory ( $ this -> config -> path ( 'cache' ) ) ; $ articles = ArticleGenerator :: getArticles ( $ this -> config -> path ( 'article' ) , $ url ) ; $ paths = $ this -> config -> paths ; $ articles -> each ( function ( $ article ) use ( $ paths ) { $ article -> createCache ( "{$paths['cache']}/article" ) ; } ) ; $ this -> generator = new SiteGenerator ( $ this -> config , $ articles ) ; $ this -> called = true ; } Util :: clearDirectory ( $ this -> config -> path ( $ type ) , true ) ; $ this -> generator -> generate ( $ type ) ; }
build static site
@param  string $type accepts public or local
@throws \InvalidArgumentException
build static site