<commit_before><?php
namespace App\App\Controller;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UploadedFileInterface;
use Tuum\Respond\Controller\PresenterTrait;
use Tuum\Respond\Interfaces\ViewDataInterface;
use Tuum\Respond\Interfaces\PresenterInterface;
use Tuum\Respond\Responder;

class UploadViewer implements PresenterInterface
{
    use PresenterTrait;

    /**
     * @param Responder $responder
     */
    public function __construct($responder)
    {
        $this->responder = $responder;
    }

    /**
     * @param array $data
     * @return ResponseInterface
     */
    protected function onGet($data)
    {
        $this->getViewData()
            ->setSuccess('Please upload a file (max 512 byte). ')
            ->setData($data)
            ->setData('isUploaded', false);
        return $this->view()->render('upload');
    }

    /**
     * @param array $data
     * @return ResponseInterface
     */
    protected function onPost($data)
    {
        $viewData = $this->setUpMessage($data['upload']);

        return $this->view($viewData)->render('upload');
    }

    /**
     * @param UploadedFileInterface      $upload
     * @return ViewDataInterface
     */
    private function setUpMessage($upload)
    {
        $viewData   = $this->getViewData();
        $error_code = $upload->getError();

        if ($error_code === UPLOAD_ERR_NO_FILE) {
            $viewData->setError('please uploaded a file');
        } elseif ($error_code === UPLOAD_ERR_FORM_SIZE) {
            $viewData->setError('uploaded file size too large!');
        } elseif ($error_code === UPLOAD_ERR_INI_SIZE) {
            $viewData->setError('uploaded file size too large!');
        } elseif ($error_code !== UPLOAD_ERR_OK) {
            $viewData->setError('uploading failed!');
        } else {
            $viewData->setSuccess('uploaded a file');
        }
        $viewData
            ->setData('isUploaded', true)
            ->setData('dump', print_r($upload, true))
            ->setData('upload', $upload)
            ->setData('error_code', $error_code);
        return $viewData;
    }
}<commit_msg>fixed upload-presenter class to implement new PresenterInterface.<commit_after><?php
namespace App\App\Controller;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UploadedFileInterface;
use Tuum\Respond\Controller\PresenterTrait;
use Tuum\Respond\Interfaces\ViewDataInterface;
use Tuum\Respond\Interfaces\PresenterInterface;
use Tuum\Respond\Responder;

class UploadViewer implements PresenterInterface
{
    use PresenterTrait;

    /**
     * @param Responder $responder
     */
    public function __construct($responder)
    {
        $this->responder = $responder;
    }

    /**
     * @param ViewDataInterface $viewData
     * @return ResponseInterface
     */
    protected function onGet($viewData)
    {
        $viewData
            ->setSuccess('Please upload a file (max 512 byte). ')
            ->setData('isUploaded', false);
        return $this->view()->render('upload');
    }

    /**
     * @param ViewDataInterface $viewData
     * @return ResponseInterface
     */
    protected function onPost($viewData)
    {
        $this->setUpMessage($viewData);

        return $this->view()->render('upload');
    }

    /**
     * @param ViewDataInterface $viewData
     */
    private function setUpMessage($viewData)
    {
        /** @var UploadedFileInterface $upload */
        $upload = $viewData->getData()['upload'];
        $error_code = $upload->getError();

        if ($error_code === UPLOAD_ERR_NO_FILE) {
            $viewData->setError('please uploaded a file');
        } elseif ($error_code === UPLOAD_ERR_FORM_SIZE) {
            $viewData->setError('uploaded file size too large!');
        } elseif ($error_code === UPLOAD_ERR_INI_SIZE) {
            $viewData->setError('uploaded file size too large!');
        } elseif ($error_code !== UPLOAD_ERR_OK) {
            $viewData->setError('uploading failed!');
        } else {
            $viewData->setSuccess('uploaded a file');
        }
        $viewData
            ->setData('isUploaded', true)
            ->setData('dump', print_r($upload, true))
            ->setData('upload', $upload)
            ->setData('error_code', $error_code);
    }
}
{'fraction_non_alphanumeric': 0.13552600886400745, 'fraction_numerical': 0.0013995801259622112, 'mean_word_length': 2.5555555555555554, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '2252082', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1256, 'n_words': 239}