<commit_before><?php
namespace Rocketeer\Satellite\Services\Applications;

use DateTime;
use Illuminate\Filesystem\FileNotFoundException;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Collection;
use Rocketeer\Satellite\Services\Pathfinder;
use SplFileInfo;
use Symfony\Component\Finder\Finder;

class ApplicationsManager
{
	/**
	 * @type Pathfinder
	 */
	protected $pathfinder;

	/**
	 * @type Filesystem
	 */
	protected $files;

	/**
	 * @param Pathfinder $pathfinder
	 * @param Filesystem $files
	 */
	public function __construct(Pathfinder $pathfinder, Filesystem $files)
	{
		$this->pathfinder = $pathfinder;
		$this->files      = $files;
	}

	/**
	 * List available applications
	 *
	 * @return Application[]
	 */
	public function getApplications()
	{
		$folder = $this->pathfinder->getApplicationsFolder();
		$apps   = $this->files->directories($folder);
		$apps   = array_map('basename', $apps);

		foreach ($apps as $key => $app) {
			$apps[$key] = $this->getApplication($app);
		}

		return $apps;
	}

	//////////////////////////////////////////////////////////////////////
	///////////////////////////// APPLICATION ////////////////////////////
	//////////////////////////////////////////////////////////////////////

	/**
	 * Get an application
	 *
	 * @param string $app
	 *<commit_msg>Skip apps that aren't yet setup<commit_after><?php
namespace Rocketeer\Satellite\Services\Applications;

use DateTime;
use Illuminate\Filesystem\FileNotFoundException;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Collection;
use Rocketeer\Satellite\Services\Pathfinder;
use SplFileInfo;
use Symfony\Component\Finder\Finder;

class ApplicationsManager
{
	/**
	 * @type Pathfinder
	 */
	protected $pathfinder;

	/**
	 * @type Filesystem
	 */
	protected $files;

	/**
	 * @param Pathfinder $pathfinder
	 * @param Filesystem $files
	 */
	public function __construct(Pathfinder $pathfinder, Filesystem $files)
	{
		$this->pathfinder = $pathfinder;
		$this->files      = $files;
	}

	/**
	 * List available applications
	 *
	 * @return Application[]
	 */
	public function getApplications()
	{
		$folder = $this->pathfinder->getApplicationsFolder();
		$apps   = $this->files->directories($folder);
		$apps   = array_map('basename', $apps);

		foreach ($apps as $key => $app) {
			// Skip apps that aren't yet setup
			if (!file_exists($folder.DS.$app.DS.'releases')) {
				continue;
			}

			$apps[$key] = $this->getApplication($app);
		}

		return $apps;
	}

	//////////////////////////////////////////////////////////////////////
	///////////////////////////// APPLICATION ////////////////////////////
	//////////////////////////////////////////////////////////////////////

	/**
	 * Get an application
	 *
	 * @param string $app
	 *
{'fraction_non_alphanumeric': 0.26178390137781, 'fraction_numerical': 0.0, 'mean_word_length': 2.1281179138321997, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '6433103', 'n_tokens_mistral': 831, 'n_tokens_neox': 750, 'n_words': 162}