<commit_before><?php namespace Flarum\Core\Groups;

use Flarum\Core\Model;
use Illuminate\Database\Eloquent\Builder;

/**
 * @todo document database columns with @property
 */
class Permission extends Model
{
    /**
     * {@inheritdoc}
     */
    protected $table = 'permissions';

    /**
     * Define the relationship with the group that this permission is for.
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function group()
    {
        return $this->belongsTo('Flarum\Core\Groups\Group', 'group_id');
    }

    /**
     * Set the keys for a save update query.
     *
     * @param Builder $query
     * @return Builder
     */
    protected function setKeysForSaveQuery(Builder $query)
    {
        $query->where('group_id', $this->group_id)
              ->where('permission', $this->permission);

        return $query;
    }

    /**
     * Get a map of permissions to the group IDs that have them.
     *
     * @return array[]
     */
    public static function map()
    {
        $permissions = [];

        foreach (static::get() as $permission) {
            $permissions[$permission->permission][] = $permission->group_id;
        }

        return $permissions;
    }<commit_msg>Convert permission IDs into strings<commit_after><?php namespace Flarum\Core\Groups;

use Flarum\Core\Model;
use Illuminate\Database\Eloquent\Builder;

/**
 * @todo document database columns with @property
 */
class Permission extends Model
{
    /**
     * {@inheritdoc}
     */
    protected $table = 'permissions';

    /**
     * Define the relationship with the group that this permission is for.
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function group()
    {
        return $this->belongsTo('Flarum\Core\Groups\Group', 'group_id');
    }

    /**
     * Set the keys for a save update query.
     *
     * @param Builder $query
     * @return Builder
     */
    protected function setKeysForSaveQuery(Builder $query)
    {
        $query->where('group_id', $this->group_id)
              ->where('permission', $this->permission);

        return $query;
    }

    /**
     * Get a map of permissions to the group IDs that have them.
     *
     * @return array[]
     */
    public static function map()
    {
        $permissions = [];

        foreach (static::get() as $permission) {
            $permissions[$permission->permission][] = (string) $permission->group_id;
        }

        return $permissions;
    }
{'fraction_non_alphanumeric': 0.12604042806183116, 'fraction_numerical': 0.0, 'mean_word_length': 2.277922077922078, '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': '5425295', 'n_tokens_mistral': 735, 'n_tokens_neox': 718, 'n_words': 185}