<commit_before><?php
/*
 * This file is part of Rocketeer
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Rocketeer\Services\Storages;

use Exception;
use Illuminate\Container\Container;
use Rocketeer\Abstracts\AbstractStorage;
use Rocketeer\Interfaces\StorageInterface;

/**
 * Provides and persists informations in local
 *
 * @author <NAME> <<EMAIL>>
 */
class LocalStorage extends AbstractStorage implements StorageInterface
{
	/**
	 * The current hash in use
	 *
	 * @var string
	 */
	protected $hash;

	/**
	 * The folder where file resides
	 *
	 * @type string
	 */
	protected $folder;

	/**
	 * Build a new LocalStorage
	 *
	 * @param Container   $app
	 * @param string      $file
	 * @param string|null $folder
	 */
	public function __construct(Container $app, $file = 'deployments', $folder = null)
	{
		parent::__construct($app, $file);

		// Create personal storage if necessary
		if (!$this->app->bound('path.storage')) {
			$folder = $this->paths->getRocketeerConfigFolder();
			$this->files->makeDirectory($folder, 0755, false, true);
		}

		// Set path to storage folder
		$this->folder = $folder ?: $this->app['path.storage'].DS.'meta';

		// Flush if necessary
		if ($this->shouldFlush()) {
			$this->destroy();
		}

		$this->set('hash', $this->getHash());
	}

	////////////////////////////////////////////////////////////////////
	//////////////////////////////// SALTS /////////////////////////////
	////////////////////////////////////////////////////////////////////

	/**
	 * Get the current salt in use
	 *
	 * @return string
	 */
	public function getHash()
	{
		// Return cached hash if any
		if ($this->hash) {
			return $this->hash;
		}

		// Get the contents of the configuration folder
		$salt   = '';
		$folder = $this->paths->getConfigurationPath();
		$files  = $this->files->glob($folder.'/*.php');

		// Remove custom files and folders
		$handles = array('events', 'tasks');
		foreach ($handles as $handle) {
			$path  = $this->app['path.rocketeer.'.$handle];
			$index = array_search($path, $files);
			if ($index !== false) {
				unset($files[$index]);<commit_msg>Update tests<commit_after><?php
/*
 * This file is part of Rocketeer
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Rocketeer\Services\Storages;

use Exception;
use Illuminate\Container\Container;
use Rocketeer\Abstracts\AbstractStorage;
use Rocketeer\Interfaces\StorageInterface;

/**
 * Provides and persists informations in local
 *
 * @author <NAME> <<EMAIL>>
 */
class LocalStorage extends AbstractStorage implements StorageInterface
{
	/**
	 * The current hash in use
	 *
	 * @var string
	 */
	protected $hash;

	/**
	 * The folder where file resides
	 *
	 * @type string
	 */
	protected $folder;

	/**
	 * Build a new LocalStorage
	 *
	 * @param Container   $app
	 * @param string      $file
	 * @param string|null $folder
	 */
	public function __construct(Container $app, $file = 'deployments', $folder = null)
	{
		parent::__construct($app, $file);

		// Create personal storage if necessary
		if (!$this->app->bound('path.storage')) {
			$folder = $this->paths->getRocketeerConfigFolder();
			$this->files->makeDirectory($folder, 0755, false, true);
		}

		// Set path to storage folder
		$this->folder = $folder ?: $this->app['path.storage'].DS.'meta';

		// Flush if necessary
		if ($this->shouldFlush()) {
			$this->destroy();
		}

		$this->set('hash', $this->getHash());
	}

	////////////////////////////////////////////////////////////////////
	//////////////////////////////// SALTS /////////////////////////////
	////////////////////////////////////////////////////////////////////

	/**
	 * Get the current salt in use
	 *
	 * @return string
	 */
	public function getHash()
	{
		// Return cached hash if any
		if ($this->hash) {
			return $this->hash;
		}

		// Get the contents of the configuration folder
		$salt   = '';
		$folder = $this->paths->getConfigurationPath();
		$files  = (array) $this->files->glob($folder.'/*.php');

		// Remove custom files and folders
		$handles = array('events', 'tasks');
		foreach ($handles as $handle) {
			$path  = $this->app['path.rocketeer.'.$handle];
			$index = array_search($path, $files);
			if ($index !== false) {
				unset($files[$index]);
{'fraction_non_alphanumeric': 0.23185800943608179, 'fraction_numerical': 0.001797348910357223, 'mean_word_length': 2.390708301599391, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 53, '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': '2005835', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1260, 'n_words': 357}