<commit_before><?php

// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

namespace App\Models;

/**
 * @property Forum\Forum $forum
 * @property int $forum_id
 * @property mixed $log_data
 * @property int $log_id
 * @property string $log_ip
 * @property string $log_operation
 * @property int $log_time
 * @property int $log_type
 * @property Forum\Post $post
 * @property int $post_id
 * @property User $reportee
 * @property int $reportee_id
 * @property Forum\Topic $topic
 * @property int $topic_id
 * @property User $user
 * @property int $user_id
 */
class Log extends Model
{
    const LOG_FORUM_ADMIN = 0;
    const LOG_FORUM_MOD = 1;
    const LOG_FORUM_CRITICAL = 2;
    const LOG_USERS = 3;
    const LOG_COMMENT_MOD = 4;
    const LOG_BEATMAPSET_MOD = 5;
    const LOG_USER_MOD = 6;

    protected $table = 'phpbb_log';
    protected $primaryKey = 'log_id';

    public $timestamps = false;
    protected $dates = ['log_time'];
    protected $dateFormat = 'U';

    public function getLogDataAttribute($value)
    {
        if (presence($value) === null) {
            return [];
        }

        return unserialize($value);
    }

    public function setLogDataAttribute($value)
    {
        $this->attributes['log_data'] = serialize($value);
    }

    public function dataForDisplay(): array|null
    {
        $logData = $this->log_data;
        $logOperation = $this->log_operation;
        $translationKey = $this->translationKey();

        $params = [];

        switch ($logOperation) {
            case 'LOG_DELETED_POST':
            case 'LOG_POST_EDITED':
            case 'LOG_RESTORE_POST':
                $post = $this->post;
                $translationKey = 'post_operation';

                if ($post === null && $logOperation !== 'LOG_POST_EDITED') {
                    return null;
                } else if ($post === null) {
                    $params['username'] = $logData[1];
                } else {
                    $params['username'] = $post->user->username;
                    $url = $post->url();
                }

                break;<commit_msg>proper typing<commit_after><?php

// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

namespace App\Models;

/**
 * @property Forum\Forum $forum
 * @property int $forum_id
 * @property mixed $log_data
 * @property int $log_id
 * @property string $log_ip
 * @property string $log_operation
 * @property int $log_time
 * @property int $log_type
 * @property Forum\Post $post
 * @property int|null $post_id
 * @property User $reportee
 * @property int $reportee_id
 * @property Forum\Topic $topic
 * @property int $topic_id
 * @property User $user
 * @property int $user_id
 */
class Log extends Model
{
    const LOG_FORUM_ADMIN = 0;
    const LOG_FORUM_MOD = 1;
    const LOG_FORUM_CRITICAL = 2;
    const LOG_USERS = 3;
    const LOG_COMMENT_MOD = 4;
    const LOG_BEATMAPSET_MOD = 5;
    const LOG_USER_MOD = 6;

    protected $table = 'phpbb_log';
    protected $primaryKey = 'log_id';

    public $timestamps = false;
    protected $dates = ['log_time'];
    protected $dateFormat = 'U';

    public function getLogDataAttribute($value)
    {
        if (presence($value) === null) {
            return [];
        }

        return unserialize($value);
    }

    public function setLogDataAttribute($value)
    {
        $this->attributes['log_data'] = serialize($value);
    }

    public function dataForDisplay(): ?array
    {
        $logData = $this->log_data;
        $logOperation = $this->log_operation;
        $translationKey = $this->translationKey();

        $params = [];

        switch ($logOperation) {
            case 'LOG_DELETED_POST':
            case 'LOG_POST_EDITED':
            case 'LOG_RESTORE_POST':
                $post = $this->post;
                $translationKey = 'post_operation';

                if ($post === null && $logOperation !== 'LOG_POST_EDITED') {
                    return null;
                } else if ($post === null) {
                    $params['username'] = $logData[1];
                } else {
                    $params['username'] = $post->user->username;
                    $url = $post->url();
                }

                break;
{'fraction_non_alphanumeric': 0.12070128118678354, 'fraction_numerical': 0.004495392222971455, 'mean_word_length': 2.2624633431085046, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, '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': '3781320', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1299, 'n_words': 348}