<commit_before><?php
namespace VikiJel\JoomlaExtensionsPackager;

use Exception;
use ZipArchive;

class Packager
{
	protected static $default_target_dir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'out';

	/**
	 * @param Package $package
	 * @param string  $dir  Target directory (defaults to ../out)
	 * @param string  $file Target filename (defaults to auto-generate from package name)
	 *
	 * @param bool    $dry_run
	 *
	 * @return string Path to created package
	 * @throws Exception
	 */
	public static function pack(Package $package, $dir = null, $file = null, $dry_run = false)
	{
		$package->prepare();

		$file = Helper::toFileName(empty($file) ? $package->getPkgPrefix() . $package->getPkgName() . '-' . $package->getVersion() . '.zip' : $file);
		$dir  = Helper::toFilePath(empty($dir) ? self::$default_target_dir : $dir);
		$path = Helper::toFilePath($dir . DIRECTORY_SEPARATOR . $file);

		if ($dry_run)
		{
			throw new Exception(
				"DRY RUN:\n" .
				'$path = ' . $path . "\n" .
				'$package = ' . print_r($package, true)
			);<commit_msg>todo...<commit_after><?php
namespace VikiJel\JoomlaExtensionsPackager;

use Exception;
use ZipArchive;

class Packager
{
	//TODO: Merge everything into Package??
	protected static $default_target_dir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'out';

	/**
	 * @param Package $package
	 * @param string  $dir  Target directory (defaults to ../out)
	 * @param string  $file Target filename (defaults to auto-generate from package name)
	 *
	 * @param bool    $dry_run
	 *
	 * @return string Path to created package
	 * @throws Exception
	 */
	public static function pack(Package $package, $dir = null, $file = null, $dry_run = false)
	{
		$package->prepare();

		$file = Helper::toFileName(empty($file) ? $package->getPkgPrefix() . $package->getPkgName() . '-' . $package->getVersion() . '.zip' : $file);
		$dir  = Helper::toFilePath(empty($dir) ? self::$default_target_dir : $dir);
		$path = Helper::toFilePath($dir . DIRECTORY_SEPARATOR . $file);

		if ($dry_run)
		{
			throw new Exception(
				"DRY RUN:\n" .
				'$path = ' . $path . "\n" .
				'$package = ' . print_r($package, true)
			);
{'fraction_non_alphanumeric': 0.15897670169026953, 'fraction_numerical': 0.0, 'mean_word_length': 3.639830508474576, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '6048337', 'n_tokens_mistral': 801, 'n_tokens_neox': 722, 'n_words': 183}