<commit_before><?php

namespace App\Ui\Silex\Web\Controller\Api\Photos;

use Silex\Application;
use Symfony\Component\HttpFoundation\Request as SilexRequest;
use Symfony\Component\HttpFoundation\JsonResponse as SilexResponse;
use Booothy\Photo\Application\Service\PostResource\Request;

final class PostResource
{
    const USE_CASE = 'photo.application.service.post_resource';

    public function __invoke(SilexRequest $silex_request, Application $app)
    {
        $quote         = $silex_request->get('quote');
        $uploaded_file = $silex_request->files->get('uploaded_file');

        $use_case = $app['container']->get(self::USE_CASE);
        $response = $use_case(new Request(
            $quote,
            $uploaded_file->getClientMimeType(),
            $uploaded_file->getRealPath()
        ));

        return new SilexResponse($response);
    }
}<commit_msg>Persisting the uploaded image in a temporary directory<commit_after><?php

namespace App\Ui\Silex\Web\Controller\Api\Photos;

use Silex\Application;
use Symfony\Component\HttpFoundation\Request as SilexRequest;
use Symfony\Component\HttpFoundation\JsonResponse as SilexResponse;
use Booothy\Photo\Application\Service\PostResource\Request;

final class PostResource
{
    const USE_CASE = 'photo.application.service.post_resource';

    public function __invoke(SilexRequest $silex_request, Application $app)
    {
        $quote         = $silex_request->get('quote');
        $uploaded_file = $silex_request->files->get('uploaded_file');
        $mime_type     = $uploaded_file->getClientMimeType();
        $file_path     = BASE_DIR . 'var/tmp/' . $uploaded_file->getFilename();
        $uploaded_file->move(BASE_DIR . 'var/tmp', $uploaded_file->getFilename());

        $use_case = $app['container']->get(self::USE_CASE);
        $response = $use_case(new Request($quote, $mime_type, $file_path));

        return new SilexResponse($response);
    }
}
{'fraction_non_alphanumeric': 0.12422360248447205, 'fraction_numerical': 0.0, 'mean_word_length': 3.8325, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '7057425', 'n_tokens_mistral': 604, 'n_tokens_neox': 593, 'n_words': 99}