<commit_before><?php

/*
 * This file is part of the Assetic package, an OpenSky project.
 *
 * (c) 2010-2011 OpenSky Project Inc
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Assetic\Filter;

use Assetic\Asset\AssetInterface;

/**
 * Runs assets through Packager.
 *
 * @link https://github.com/kamicane/packager
 * @author <NAME> <<EMAIL>>
 */
class PackagerFilter implements FilterInterface
{
    private $packages = array();

    public function addPackage($package)
    {
        $this->packages[] = $package;
    }

    public function filterLoad(AssetInterface $asset)
    {
        static $manifest = <<<EOF
name: Application
sources: [source.js]

EOF;

        $package = sys_get_temp_dir().'/assetic_packager_'.substr(sha1(time().rand(11111, 99999)), 0, 7);

        mkdir($package);
        file_put_contents($package.'/package.yml', $manifest);
        file_put_contents($package.'/source.js', $asset->getContent());

        $packager = new \Packager(array_merge(array($package), $this->packages));
        $content = $packager->build(array(), array(), array('Application'));

        unlink($package.'/package.yml');
        unlink($package.'/source.js');
        rmdir($package);
<commit_msg>added constructor argument to PackagerFilter<commit_after><?php

/*
 * This file is part of the Assetic package, an OpenSky project.
 *
 * (c) 2010-2011 OpenSky Project Inc
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Assetic\Filter;

use Assetic\Asset\AssetInterface;

/**
 * Runs assets through Packager.
 *
 * @link https://github.com/kamicane/packager
 * @author <NAME> <<EMAIL>>
 */
class PackagerFilter implements FilterInterface
{
    private $packages;

    public function __construct(array $packages = array())
    {
        $this->packages = $packages;
    }

    public function addPackage($package)
    {
        $this->packages[] = $package;
    }

    public function filterLoad(AssetInterface $asset)
    {
        static $manifest = <<<EOF
name: Application
sources: [source.js]

EOF;

        $package = sys_get_temp_dir().'/assetic_packager_'.substr(sha1(time().rand(11111, 99999)), 0, 7);

        mkdir($package);
        file_put_contents($package.'/package.yml', $manifest);
        file_put_contents($package.'/source.js', $asset->getContent());

        $packager = new \Packager(array_merge(array($package), $this->packages));
        $content = $packager->build(array(), array(), array('Application'));

        unlink($package.'/package.yml');
        unlink($package.'/source.js');
        rmdir($package);

{'fraction_non_alphanumeric': 0.14405543398978848, 'fraction_numerical': 0.015317286652078774, 'mean_word_length': 3.4385113268608416, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, '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': '7471149', 'n_tokens_mistral': 859, 'n_tokens_neox': 791, 'n_words': 198}