<commit_before><?php

namespace Storeman;

use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;

/**
 * Compiles the application into a standalone phar which is suitable for distribution.
 * Based on the composer counterpart: https://github.com/composer/composer/blob/master/src/Composer/Compiler.php
 */
class PharCompiler
{
    /**
     * @var Filesystem
     */
    protected $filesystem;

    public function __construct()
    {
        $this->filesystem = new Filesystem();
    }

    /**
     * Compiles the phar into the given target file path and the given file mode.
     *
     * @param string $targetFilePath
     * @param int $mode
     */
    public function compile(string $targetFilePath, int $mode = 0744): void
    {
        if (file_exists($targetFilePath))
        {
            $this->filesystem->remove($targetFilePath);
        }


        $phar = new \Phar($targetFilePath, 0, 'storeman.phar');
        $phar->setSignatureAlgorithm(\Phar::SHA256);

        $phar->startBuffering();

        $this->addSourceFiles($phar);
        $this->addDependencyFiles($phar);

        $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../bootstrap.php'));
        $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../bin/storeman'));

        $phar->setStub($this->getStub());
        $phar->compressFiles(\Phar::GZ);

        $phar->stopBuffering();

        $this->filesystem->chmod($targetFilePath, $mode);
    }

    protected function addSourceFiles(\Phar $phar): void
    {
        $finder = new Finder();
        $finder->files()
            ->ignoreVCS(true)<commit_msg>Raised default build artifact file mode to 0755<commit_after><?php

namespace Storeman;

use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;

/**
 * Compiles the application into a standalone phar which is suitable for distribution.
 * Based on the composer counterpart: https://github.com/composer/composer/blob/master/src/Composer/Compiler.php
 */
class PharCompiler
{
    /**
     * @var Filesystem
     */
    protected $filesystem;

    public function __construct()
    {
        $this->filesystem = new Filesystem();
    }

    /**
     * Compiles the phar into the given target file path and the given file mode.
     *
     * @param string $targetFilePath
     * @param int $mode
     */
    public function compile(string $targetFilePath, int $mode = 0755): void
    {
        if (file_exists($targetFilePath))
        {
            $this->filesystem->remove($targetFilePath);
        }


        $phar = new \Phar($targetFilePath, 0, 'storeman.phar');
        $phar->setSignatureAlgorithm(\Phar::SHA256);

        $phar->startBuffering();

        $this->addSourceFiles($phar);
        $this->addDependencyFiles($phar);

        $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../bootstrap.php'));
        $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../bin/storeman'));

        $phar->setStub($this->getStub());
        $phar->compressFiles(\Phar::GZ);

        $phar->stopBuffering();

        $this->filesystem->chmod($targetFilePath, $mode);
    }

    protected function addSourceFiles(\Phar $phar): void
    {
        $finder = new Finder();
        $finder->files()
            ->ignoreVCS(true)
{'fraction_non_alphanumeric': 0.14119804400977995, 'fraction_numerical': 0.006112469437652812, 'mean_word_length': 2.661073825503356, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, 'https://': 2, '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': '6233681', 'n_tokens_mistral': 1001, 'n_tokens_neox': 962, 'n_words': 206}