<commit_before><?php
namespace Freischutz\Application;

use Phalcon\Mvc\User\Component;

/**
 * Freischutz\Application\Data
 */
class Data extends Component
{
    private $data;

    /**
     * Constructor.
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * Get raw data.
     *
     * @return string|binary
     */
    public function getRaw()
    {
        return $this->data;
    }

    /**
     * Handle JSON data.
     *
     * @param bool $assoc (optional) Return associative array instead of object.
     * @return object|array|false<commit_msg>Add generic get() method for data<commit_after><?php
namespace Freischutz\Application;

use Phalcon\Mvc\User\Component;

/**
 * Freischutz\Application\Data
 */
class Data extends Component
{
    private $data;

    /**
     * Constructor.
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * Get data handled according to content-type.
     *
     * @return mixed
     */
    public function get()
    {
        switch ($this->request->getHeader('CONTENT_TYPE')) {
            case 'application/json':
                $data = $this->getJson();
                break;
            case 'application/xml':
            case 'text/xml':
                $data = $this->getXml();
                break;
            default:
                $data = $this->getRaw();
                break;
        }
        return $data;
    }

    /**
     * Get raw data.
     *
     * @return string|binary
     */
    public function getRaw()
    {
        return $this->data;
    }

    /**
     * Handle JSON data.
     *
     * @param bool $assoc (optional) Return associative array instead of object.
     * @return object|array|false
{'fraction_non_alphanumeric': 0.12521150592216582, 'fraction_numerical': 0.0, 'mean_word_length': 1.696048632218845, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1426822', 'n_tokens_mistral': 522, 'n_tokens_neox': 510, 'n_words': 121}