<commit_before><?php
namespace App\Action;

use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Views\Twig;
use Psr\Log\LoggerInterface;
use RKA\Session;
use Slim\Flash\Messages;
use App\Classes\Log;

final class HomeAction
{
    private $view;
    private $logger;
    private $flash;
    private $session;

    private $log;

    // 1ページに表示する投稿数
    const DEFAULT_PER_PAFE = 10;

    public function __construct(Twig $view, LoggerInterface $logger, Session $session, Messages $flash, Log $log)
    {
        $this->view    = $view;
        $this->logger  = $logger;
        $this->flash   = $flash;
        $this->session = $session;
        $this->log     = $log;
    }

    // データを表示するサイズに切り取る
    public function dataSplice($data, $page, $per_page = self::DEFAULT_PER_PAFE)
    {
        if ($data) {
            $data = array_splice($data, $page * $per_page, $per_page);
        }

        return $data;
    }

    // ホーム画面（トップページ）の表示
    public function dispatch(Request $request, Response $response)
    {
        $this->logger->info("Home page action dispatched");

        $response = $response->withHeader('X-Frame-Options', 'SAMEORIGIN');

        // CSRF
        $csrf_name = $request->getAttribute('csrf_name');
        $csrf_value = $request->getAttribute('csrf_value');

        // 表示するログの用意
        $page = $request->getParam('page');
        $per_page = self::DEFAULT_PER_PAFE;
        $all_data = $this->log->dataRead();
        $data_count = count($all_data);
        $data = $this->dataSplice($all_data, $page, $per_page);

        $message = $this->flash->getMessage('resultMessage');
        $error = $this->flash->getMessage('errorMessage');

        // 書き込んだときの情報を読み込み
        $name = $this->session->get('name');
        $email = $this->session->get('email');

        $this->view->render(
            $response,
            'home.twig',
            [
                'csrf_name' => $csrf_name,
                'csrf_value' => $csrf_value,
                'data' => $data,
                'message' => $message[0],
                'error' => $error[0],
                'count' => $data_count,
                'current_page' => $page,
                'per_page' => $per_page,
                'name' => $name,
                'email' => $email
            ]
        );
        return $response;
    }<commit_msg>Fix typo<commit_after><?php
namespace App\Action;

use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Views\Twig;
use Psr\Log\LoggerInterface;
use RKA\Session;
use Slim\Flash\Messages;
use App\Classes\Log;

final class HomeAction
{
    private $view;
    private $logger;
    private $flash;
    private $session;

    private $log;

    // 1ページに表示する投稿数
    const DEFAULT_PER_PAGE = 10;

    public function __construct(Twig $view, LoggerInterface $logger, Session $session, Messages $flash, Log $log)
    {
        $this->view    = $view;
        $this->logger  = $logger;
        $this->flash   = $flash;
        $this->session = $session;
        $this->log     = $log;
    }

    // データを表示するサイズに切り取る
    public function dataSplice($data, $page, $per_page = self::DEFAULT_PER_PAGE)
    {
        if ($data) {
            $data = array_splice($data, $page * $per_page, $per_page);
        }

        return $data;
    }

    // ホーム画面（トップページ）の表示
    public function dispatch(Request $request, Response $response)
    {
        $this->logger->info("Home page action dispatched");

        $response = $response->withHeader('X-Frame-Options', 'SAMEORIGIN');

        // CSRF
        $csrf_name = $request->getAttribute('csrf_name');
        $csrf_value = $request->getAttribute('csrf_value');

        // 表示するログの用意
        $page = $request->getParam('page');
        $per_page = self::DEFAULT_PER_PAGE;
        $all_data = $this->log->dataRead();
        $data_count = count($all_data);
        $data = $this->dataSplice($all_data, $page, $per_page);

        $message = $this->flash->getMessage('resultMessage');
        $error = $this->flash->getMessage('errorMessage');

        // 書き込んだときの情報を読み込み
        $name = $this->session->get('name');
        $email = $this->session->get('email');

        $this->view->render(
            $response,
            'home.twig',
            [
                'csrf_name' => $csrf_name,
                'csrf_value' => $csrf_value,
                'data' => $data,
                'message' => $message[0],
                'error' => $error[0],
                'count' => $data_count,
                'current_page' => $page,
                'per_page' => $per_page,
                'name' => $name,
                'email' => $email
            ]
        );
        return $response;
    }
{'fraction_non_alphanumeric': 0.15101604278074865, 'fraction_numerical': 0.0021390374331550803, 'mean_word_length': 2.028497409326425, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 71, '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': '3686059', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1552, 'n_words': 277}