<commit_before><?php namespace Aedart\Scaffold;

use Aedart\Scaffold\Console\BuildCommand;
use Aedart\Scaffold\Console\IndexCommand;
use Aedart\Scaffold\Console\InstallCommand;
use Aedart\Scaffold\Containers\IoC;
use Symfony\Component\Console\Application;
use Composer\Factory;

/**
 * Scaffold Application
 *
 * @author <NAME> <<EMAIL>>
 * @package Aedart\Scaffold
 */
class ScaffoldApplication extends Application
{
    /**
     * List of this application's commands
     *
     * @var string[]
     */
    protected $appCommands = [
        InstallCommand::class,
        BuildCommand::class,
        IndexCommand::class
    ];

    /**
     * Scaffold Application constructor.
     */
    public function __construct()
    {
        $name = 'Aedart Scaffold Installer';
        $version = $this->resolveApplicationVersion();

        parent::__construct($name, $version);

        $this->setupApplication();
    }

    /**
     * Setup this application
     */
    protected function setupApplication()
    {
        $this->bootIoC();
        $this->registerCommands();
    }

    /**
     * Boot the IoC
     */
    protected function bootIoC()
    {
        IoC::boot();
    }

    /**
     * Register this application's console commands
     */
    protected function registerCommands()
    {
        foreach($this->appCommands as $command){
            $this->add( new $command);
        }
    }

    /**
     * Returns this application's version from it's
     * package composer file
     *
     * @return string Package version or UNKNOWN if not able to read composer file
     */
    protected function resolveApplicationVersion()
    {
        // TODO: Use composer to obtain vendor dir...
        // TODO: Search for installed.json inside composer's directory inside the vendor folder
        // TODO: Find this package - obtain version number
        // TODO: ...fallback?

        $pathToComposerFile = __DIR__ . '/../composer.json';
        if(!file_exists($pathToComposerFile)){
            return 'UNKNOWN';
        }

        $composer = json_decode(file_get_contents($pathToComposerFile), true);

        return $composer['extra']['branch-alias']['dev-master'];
    }
}<commit_msg>Use installed version reader component<commit_after><?php namespace Aedart\Scaffold;

use Aedart\Installed\Version\Reader;
use Aedart\Scaffold\Console\BuildCommand;
use Aedart\Scaffold\Console\IndexCommand;
use Aedart\Scaffold\Console\InstallCommand;
use Aedart\Scaffold\Containers\IoC;
use Symfony\Component\Console\Application;
use Composer\Factory as ComposerFactory;

/**
 * Scaffold Application
 *
 * @author <NAME> <<EMAIL>>
 * @package Aedart\Scaffold
 */
class ScaffoldApplication extends Application
{
    /**
     * List of this application's commands
     *
     * @var string[]
     */
    protected $appCommands = [
        InstallCommand::class,
        BuildCommand::class,
        IndexCommand::class
    ];

    /**
     * Scaffold Application constructor.
     */
    public function __construct()
    {
        $name = 'Aedart Scaffold Installer';
        $version = $this->resolveApplicationVersion();

        parent::__construct($name, $version);

        $this->setupApplication();
    }

    /**
     * Setup this application
     */
    protected function setupApplication()
    {
        $this->bootIoC();
        $this->registerCommands();
    }

    /**
     * Boot the IoC
     */
    protected function bootIoC()
    {
        IoC::boot();
    }

    /**
     * Register this application's console commands
     */
    protected function registerCommands()
    {
        foreach($this->appCommands as $command){
            $this->add( new $command);
        }
    }

    /**
     * Returns this application's version from it's
     * package composer file
     *
     * @return string Package version or UNKNOWN if not able to read composer file
     */
    protected function resolveApplicationVersion()
    {
        return (new Reader())->getVersion('aedart/scaffold');
    }
}
{'fraction_non_alphanumeric': 0.11637179167704959, 'fraction_numerical': 0.0, 'mean_word_length': 2.4454935622317597, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1851765', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1113, 'n_words': 263}