<commit_before><?php

namespace BootstrapApp\Apache;

use Illuminate\Filesystem\Filesystem;


/**
 * Class ApacheFilesGenerator
 * @package BootstrapApp\Apache
 */
class ApacheFilesGenerator {


    /**
     * @var Filesystem
     */
    private $files;
    /**
     * @var
     */
    private $app_name;
    /**
     * @var
     */
    private $base_dev_path;
    /**
     * @var null
     */
    private $apache_base_path;
    /**
     * @var string
     */
    private $apache_version;


    /**
     * @param Filesystem $files
     * @param $app_name
     * @param $base_dev_path
     * @param null $apache_base_path
     * @param string $apache_version
     */
    public function __construct(Filesystem $files, $app_name, $base_dev_path, $apache_base_path = null, $apache_version = "24")
    {
        $this->files = $files;
        $this->app_name = $app_name;
        $this->base_dev_path = $base_dev_path;
        $this->apache_base_path = $apache_base_path;
        $this->apache_version = $apache_version;
    }

    /**
     * @return string
     */
    public function getApacheVersion()
    {
        return $this->apache_version;
    }

    /**
     * @param string $apache_version
     */
    public function setApacheVersion($apache_version)
    {
        $this->apache_version = $apache_version;
    }



    /**
     * Get the path to where we should store the migration.
     *
     * @param  string $name
     * @return string
     */
    protected function getPath($name)
    {
        ($this->apache_base_path != null) ? $apache_base_path = $this->apache_base_path : $apache_base_path = "/etc/apache2/";
        
        if ($this->apache_version === "24") {
            return $apache_base_path . '/conf-available/' . $name . '.conf';
        } else {
            return $apache_base_path . '/conf.d/' . $name . '.conf';
        }

    }


    /**
     * @param bool $force
     * @return string
     */
    public function createAliasForLaravel( $force = true)
    {
        if ($this->files->exists($path = $this->getPath($this->app_name)))
        {
            if (!$force)
            {
                return 'File already exists!';
            }
        }

        $this->makeDirectory($path);
        $this->files->put($path, $this->compileAliasForLaravel($this->apache_version));
    }

    /**
     * Build the directory for the class if necessary.
     *
     * @param  string $path
     * @return string
     */
    protected function makeDirectory($path)
    {
        if (!$this->files->isDirectory(dirname($path)))
        {
            $this->files->makeDirectory(dirname($path), 0775, true, true);
        }
    }


    /**
     * @return string
     */
    public function compileAliasForLaravel()
    {<commit_msg>compileAliasForLaravel as no arguments<commit_after><?php

namespace BootstrapApp\Apache;

use Illuminate\Filesystem\Filesystem;


/**
 * Class ApacheFilesGenerator
 * @package BootstrapApp\Apache
 */
class ApacheFilesGenerator {


    /**
     * @var Filesystem
     */
    private $files;
    /**
     * @var
     */
    private $app_name;
    /**
     * @var
     */
    private $base_dev_path;
    /**
     * @var null
     */
    private $apache_base_path;
    /**
     * @var string
     */
    private $apache_version;


    /**
     * @param Filesystem $files
     * @param $app_name
     * @param $base_dev_path
     * @param null $apache_base_path
     * @param string $apache_version
     */
    public function __construct(Filesystem $files, $app_name, $base_dev_path, $apache_base_path = null, $apache_version = "24")
    {
        $this->files = $files;
        $this->app_name = $app_name;
        $this->base_dev_path = $base_dev_path;
        $this->apache_base_path = $apache_base_path;
        $this->apache_version = $apache_version;
    }

    /**
     * @return string
     */
    public function getApacheVersion()
    {
        return $this->apache_version;
    }

    /**
     * @param string $apache_version
     */
    public function setApacheVersion($apache_version)
    {
        $this->apache_version = $apache_version;
    }



    /**
     * Get the path to where we should store the migration.
     *
     * @param  string $name
     * @return string
     */
    protected function getPath($name)
    {
        ($this->apache_base_path != null) ? $apache_base_path = $this->apache_base_path : $apache_base_path = "/etc/apache2/";
        
        if ($this->apache_version === "24") {
            return $apache_base_path . '/conf-available/' . $name . '.conf';
        } else {
            return $apache_base_path . '/conf.d/' . $name . '.conf';
        }

    }


    /**
     * @param bool $force
     * @return string
     */
    public function createAliasForLaravel( $force = true)
    {
        if ($this->files->exists($path = $this->getPath($this->app_name)))
        {
            if (!$force)
            {
                return 'File already exists!';
            }
        }

        $this->makeDirectory($path);
        $this->files->put($path, $this->compileAliasForLaravel());
    }

    /**
     * Build the directory for the class if necessary.
     *
     * @param  string $path
     * @return string
     */
    protected function makeDirectory($path)
    {
        if (!$this->files->isDirectory(dirname($path)))
        {
            $this->files->makeDirectory(dirname($path), 0775, true, true);
        }
    }


    /**
     * @return string
     */
    public function compileAliasForLaravel()
    {
{'fraction_non_alphanumeric': 0.13610003624501632, 'fraction_numerical': 0.0032620514679231605, 'mean_word_length': 1.9656098871574423, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 48, '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': '7632147', 'n_tokens_mistral': 1721, 'n_tokens_neox': 1673, 'n_words': 331}