<commit_before><?php
/**
 * Class Minify_Controller_MinApp
 * @package Minify
 */

/**
 * Controller class for requests to /min/index.php
 * 
 * @package Minify
 * @author <NAME> <<EMAIL>>
 */
class Minify_Controller_MinApp extends Minify_Controller_Base {

    /**
     * Set up groups of files as sources
     * 
     * @param array $options controller and Minify options
     *
     * @return array Minify options
     */
    public function createConfiguration(array $options) {
        // PHP insecure by default: realpath() and other FS functions can't handle null bytes.
        $get = $this->env->get();
        foreach (array('g', 'b', 'f') as $key) {
            if (isset($get[$key])) {
                $get[$key] = str_replace("\x00", '', (string)$get[$key]);
            }
        }

        // filter controller options
        $localOptions = array_merge(
            array(
                'groupsOnly' => false,
                'groups' => array(),
            )
            ,(isset($options['minApp']) ? $options['minApp'] : array())
        );
        unset($options['minApp']);

        $sources = array();
        $selectionId = '';
        $firstMissingResource = null;

        if (isset($get['g'])) {
            // add group(s)
            $selectionId .= 'g=' . $get['g'];
            $keys = explode(',', $get['g']);
            if ($keys != array_unique($keys)) {
                $this->log("Duplicate group key found.");
                return new Minify_ServeConfiguration($options);
            }
            $keys = explode(',', $get['g']);
            foreach ($keys as $key) {
                if (! isset($localOptions['groups'][$key])) {
                    $this->log("A group configuration for \"{$key}\" was not found");
                    return new Minify_ServeConfiguration($options);
                }
                $files = $localOptions['groups'][$key];
                // if $files is a single object, casting will break it
                if (is_object($files)) {
                    $files = array($files);
                } elseif (! is_array($files)) {
                    $files = (array)$files;
                }
                foreach ($files as $file) {
                    if ($file instanceof Minify_SourceInterface) {
                        $sources[] = $file;
                        continue;
                    }
                    try {
                        $source = $this->sourceFactory->makeSource(array(
                            'filepath' => $file,
                        ));
                        $sources[] = $source;
                    } catch (Minify_Source_FactoryException $e) {
                        $this->log($e->getMessage());<commit_msg>remove duplicate $keys. refs bceffd5<commit_after><?php
/**
 * Class Minify_Controller_MinApp
 * @package Minify
 */

/**
 * Controller class for requests to /min/index.php
 * 
 * @package Minify
 * @author <NAME> <<EMAIL>>
 */
class Minify_Controller_MinApp extends Minify_Controller_Base {

    /**
     * Set up groups of files as sources
     * 
     * @param array $options controller and Minify options
     *
     * @return array Minify options
     */
    public function createConfiguration(array $options) {
        // PHP insecure by default: realpath() and other FS functions can't handle null bytes.
        $get = $this->env->get();
        foreach (array('g', 'b', 'f') as $key) {
            if (isset($get[$key])) {
                $get[$key] = str_replace("\x00", '', (string)$get[$key]);
            }
        }

        // filter controller options
        $localOptions = array_merge(
            array(
                'groupsOnly' => false,
                'groups' => array(),
            )
            ,(isset($options['minApp']) ? $options['minApp'] : array())
        );
        unset($options['minApp']);

        $sources = array();
        $selectionId = '';
        $firstMissingResource = null;

        if (isset($get['g'])) {
            // add group(s)
            $selectionId .= 'g=' . $get['g'];
            $keys = explode(',', $get['g']);
            if ($keys != array_unique($keys)) {
                $this->log("Duplicate group key found.");
                return new Minify_ServeConfiguration($options);
            }
            foreach ($keys as $key) {
                if (! isset($localOptions['groups'][$key])) {
                    $this->log("A group configuration for \"{$key}\" was not found");
                    return new Minify_ServeConfiguration($options);
                }
                $files = $localOptions['groups'][$key];
                // if $files is a single object, casting will break it
                if (is_object($files)) {
                    $files = array($files);
                } elseif (! is_array($files)) {
                    $files = (array)$files;
                }
                foreach ($files as $file) {
                    if ($file instanceof Minify_SourceInterface) {
                        $sources[] = $file;
                        continue;
                    }
                    try {
                        $source = $this->sourceFactory->makeSource(array(
                            'filepath' => $file,
                        ));
                        $sources[] = $source;
                    } catch (Minify_Source_FactoryException $e) {
                        $this->log($e->getMessage());
{'fraction_non_alphanumeric': 0.14185961043733922, 'fraction_numerical': 0.0009187798603454612, 'mean_word_length': 1.4740909090909091, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, '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': '1867765', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1355, 'n_words': 338}