<commit_before><?php

/*
 * This file is part of the ONGR package.
 *
 * (c) NFQ Technologies UAB <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace ONGR\ApiBundle\Controller;

use ONGR\ApiBundle\Service\Crud;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

/**
 * Abstraction for rest api controller.
 */
class AbstractRestController extends Controller
{

    /** @var  Crud $crud */
    private $crud;

    /**
     * Get CRUD Service
     *
     * @return Crud
     */
    public function getCrud()
    {

        if (!$this->crud) {
            if (!$this->container->has('ongr_api.crud')) {
                throw new \RuntimeException('Please set RESTful CRUD Service.');
            }
            $this->crud = $this->container->get('ongr_api.crud');
        }

        return $this->crud;
    }

    /**
     * Set CRUD Service
     *
     * @param Crud $crud
     */
    public function setCrud(Crud $crud)
    {
        $this->crud = $crud;
    }

    /**
     * Renders rest response.
     *
     * @param mixed $data
     * @param int $statusCode
     * @param array $headers
     *
     * @return Response|array
     */
    public function renderRest(
        $data,
        $statusCode = Response::HTTP_OK,
        $headers = []
    ) {

        if ($data == null) {
            return $this->renderError("NOT FOUND", Response::HTTP_NOT_FOUND);
        }

        return $this->get('ongr_api.rest_response_view_handler')
            ->handleView($data, $statusCode, $headers);
    }

    /**
     * Error Response
     *
     * @param string $message
     * @param int $statusCode
     * @return array|Response
     */
    public function renderError(
        $message,
        $statusCode = Response::HTTP_BAD_REQUEST
    ) {

        // TODO: Add more information about this Error

        $response = [
            'errors' => [],
            'message' => $message,
            'code' => $statusCode
        ];

        return $this->renderRest($response, $statusCode);
    }
}<commit_msg>cleaned batch controller<commit_after><?php

/*
 * This file is part of the ONGR package.
 *
 * (c) NFQ Technologies UAB <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace ONGR\ApiBundle\Controller;

use ONGR\ApiBundle\Service\Crud;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

/**
 * Batch controller
 */
class BatchController extends Controller
{
}
{'fraction_non_alphanumeric': 0.12005965697240865, 'fraction_numerical': 0.0, 'mean_word_length': 2.2879901960784315, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 22, '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': '3841848', 'n_tokens_mistral': 797, 'n_tokens_neox': 782, 'n_words': 204}