<commit_before><?php

namespace Cytron\Bundle\BabitchBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use FOS\RestBundle\Request\ParamFetcher;
use FOS\RestBundle\Routing\ClassResourceInterface;
use FOS\RestBundle\Controller\Annotations\QueryParam;
use FOS\RestBundle\Controller\Annotations\Route;
use FOS\RestBundle\Controller\FOSRestController;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;

use Cytron\Bundle\BabitchBundle\Form\GameType;
use Cytron\Bundle\BabitchBundle\Controller\PaginatorTrait;

/**
 * Class GameController
 *
 * @package Cytron\Bundle\BabitchBundle\Controller
 */
class GameController extends FOSRestController implements ClassResourceInterface
{
    use PaginatorTrait;

    /**
     * Create an game
     *
     * @param Request $request
     *
     * @return \FOS\RestBundle\View\View
     *
     * @ApiDoc(
     *  section="Game",
     *   description="Create an game",
     *   input={"class"="Cytron\Bundle\BabitchBundle\Form\GameType", "name"=""},
     *   output="Cytron\Bundle\BabitchBundle\Entity\Game",
     *   statusCodes={
     *     201="Game created",
     *     400="Bad request",
     *     422="Unprocessable entity"
     *   }
     * )
     */
    public function cpostAction(Request $request)
    {
        $manager = $this->get('cytron_babitch.game.manager');
        $entity  = $manager->create();
        $form    = $this->container->get('form.factory')->createNamed('', new GameType(), $entity);

        $form->submit($request);

        if ($form->isValid()) {
            $manager->persist($entity, true);

            return $this->view($entity, 201, array(
                'Location' => $this->generateUrl('get_game', ['id' => $entity->getId()], true),
            ));
        }

        return $this->view($form, 422);
    }

    /**
     * Get game
     *
     * @param integer $id Game id
     *
     * @return \FOS\RestBundle\View\View
     *
     * @ApiDoc(
     *  section="Game",
     *   description="Get article details",
     *   output="Cytron\Bundle\BabitchBundle\Entity\Game",
     *   statusCodes={
     *     200="OK",
     *     400="Bad request",
     *     404="Game not found"
     *   }
     * )
     * 
     * @Route(requirements={
     *   "id"="\d+"
     * })
     */
    public function getAction($id)
    {
        $game = $this->get('cytron_babitch.game.manager')->getRepository()->find($id);

        if (is_null($game)) {
            return $this->view(sprintf('Game with id %s not found', $id), 404);
        }

        return $this->view($game, 200);
    }

    /**
     * Game list
     *
     * @param ParamFetcher $paramFetcher
     *
     * @return \FOS\RestBundle\View\View
     *
     * @QueryParam(name="page", requirements="\d+", default="1", description="Current page index")
     * @QueryParam(name="per_page", requirements="\d+", default="20", description="Number of elements displayed per page")
     *
     * @ApiDoc(
     *  section="Game",
     *   description="Get article list",
     *   output="Cytron\Bundle\BabitchBundle\Entity\Game",
     *   statusCodes={
     *     200="OK",
     *     400="Bad request"
     *   }
     * )
     */
    public function cgetAction(ParamFetcher $paramFetcher)
    {
        list($start, $limit) = $this->getStartAndLimitFromParams($paramFetcher);

        $repository = $this->get('cytron_babitch.game.manager')->getRepository();
        $entities   = $repository->findBy([], ['id' => 'DESC'], $limit, $start);

        return $this->view($entities, 200);
    }<commit_msg>same default value for per_page parameters<commit_after><?php

namespace Cytron\Bundle\BabitchBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use FOS\RestBundle\Request\ParamFetcher;
use FOS\RestBundle\Routing\ClassResourceInterface;
use FOS\RestBundle\Controller\Annotations\QueryParam;
use FOS\RestBundle\Controller\Annotations\Route;
use FOS\RestBundle\Controller\FOSRestController;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;

use Cytron\Bundle\BabitchBundle\Form\GameType;
use Cytron\Bundle\BabitchBundle\Controller\PaginatorTrait;

/**
 * Class GameController
 *
 * @package Cytron\Bundle\BabitchBundle\Controller
 */
class GameController extends FOSRestController implements ClassResourceInterface
{
    use PaginatorTrait;

    /**
     * Create an game
     *
     * @param Request $request
     *
     * @return \FOS\RestBundle\View\View
     *
     * @ApiDoc(
     *  section="Game",
     *   description="Create an game",
     *   input={"class"="Cytron\Bundle\BabitchBundle\Form\GameType", "name"=""},
     *   output="Cytron\Bundle\BabitchBundle\Entity\Game",
     *   statusCodes={
     *     201="Game created",
     *     400="Bad request",
     *     422="Unprocessable entity"
     *   }
     * )
     */
    public function cpostAction(Request $request)
    {
        $manager = $this->get('cytron_babitch.game.manager');
        $entity  = $manager->create();
        $form    = $this->container->get('form.factory')->createNamed('', new GameType(), $entity);

        $form->submit($request);

        if ($form->isValid()) {
            $manager->persist($entity, true);

            return $this->view($entity, 201, array(
                'Location' => $this->generateUrl('get_game', ['id' => $entity->getId()], true),
            ));
        }

        return $this->view($form, 422);
    }

    /**
     * Get game
     *
     * @param integer $id Game id
     *
     * @return \FOS\RestBundle\View\View
     *
     * @ApiDoc(
     *  section="Game",
     *   description="Get article details",
     *   output="Cytron\Bundle\BabitchBundle\Entity\Game",
     *   statusCodes={
     *     200="OK",
     *     400="Bad request",
     *     404="Game not found"
     *   }
     * )
     *
     * @Route(requirements={
     *   "id"="\d+"
     * })
     */
    public function getAction($id)
    {
        $game = $this->get('cytron_babitch.game.manager')->getRepository()->find($id);

        if (is_null($game)) {
            return $this->view(sprintf('Game with id %s not found', $id), 404);
        }

        return $this->view($game, 200);
    }

    /**
     * Game list
     *
     * @param ParamFetcher $paramFetcher
     *
     * @return \FOS\RestBundle\View\View
     *
     * @QueryParam(name="page", requirements="\d+", default="1", description="Current page index")
     * @QueryParam(name="per_page", requirements="\d+", default="50", description="Number of elements displayed per page")
     *
     * @ApiDoc(
     *  section="Game",
     *   description="Get article list",
     *   output="Cytron\Bundle\BabitchBundle\Entity\Game",
     *   statusCodes={
     *     200="OK",
     *     400="Bad request"
     *   }
     * )
     */
    public function cgetAction(ParamFetcher $paramFetcher)
    {
        list($start, $limit) = $this->getStartAndLimitFromParams($paramFetcher);

        $repository = $this->get('cytron_babitch.game.manager')->getRepository();
        $entities   = $repository->findBy([], ['id' => 'DESC'], $limit, $start);

        return $this->view($entities, 200);
    }
{'fraction_non_alphanumeric': 0.15771622385528547, 'fraction_numerical': 0.011871113623516111, 'mean_word_length': 2.5544952285283777, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 53, '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': '6539665', 'n_tokens_mistral': 2313, 'n_tokens_neox': 2196, 'n_words': 363}