<commit_before><?php

/**
 * This file is part of Laravel Credentials by <NAME>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at http://bit.ly/UWsjkb.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace GrahamCampbell\Credentials\Http\Controllers;

use GrahamCampbell\Credentials\Http\Middleware\Auth\Admin;
use GrahamCampbell\Credentials\Http\Middleware\Auth\Mod;
use GrahamCampbell\Credentials\Http\Middleware\Auth\User;
use Illuminate\Routing\Controller;

/**
 * This is the abstract controller class.
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright 2013-2014 <NAME>
 * @license   <https://github.com/GrahamCampbell/Laravel-Credentials/blob/master/LICENSE.md> Apache 2.0
 */
abstract class AbstractController extends Controller
{
    /**
     * A list of methods protected by user permissions.
     *
     * @var string[]
     */
    protected $users = [];

    /**
     * A list of methods protected by mod permissions.
     *
     * @var string[]
     */
    protected $mods = [];

    /**
     * A list of methods protected by admin permissions.
     *
     * @var string[]
     */
    protected $admins = [];

    /**
     * Create a new instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware(User::class, ['only' => $this->users]);
        $this->middleware(Mod::class, ['only' => $this->mods]);
        $this->middleware(Admin::class, ['only' => $this->admins]);
    }

    /**
     * Set the permission.
     *
     * @param string $action
     * @param string $permission
     *
     * @return void
     */
    protected function setPermission($action, $permission)
    {
        $this->{$permission.'s'}[] = $action;
    }

    /**
     * Set the permissions.
     *
     * @param string[] $permissions<commit_msg>Work around laravel bug<commit_after><?php

/**
 * This file is part of Laravel Credentials by <NAME>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at http://bit.ly/UWsjkb.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace GrahamCampbell\Credentials\Http\Controllers;

use GrahamCampbell\Credentials\Http\Middleware\Auth\Admin;
use GrahamCampbell\Credentials\Http\Middleware\Auth\Mod;
use GrahamCampbell\Credentials\Http\Middleware\Auth\User;
use Illuminate\Routing\Controller;

/**
 * This is the abstract controller class.
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright 2013-2014 <NAME>
 * @license   <https://github.com/GrahamCampbell/Laravel-Credentials/blob/master/LICENSE.md> Apache 2.0
 */
abstract class AbstractController extends Controller
{
    /**
     * A list of methods protected by user permissions.
     *
     * @var string[]
     */
    protected $users = [];

    /**
     * A list of methods protected by mod permissions.
     *
     * @var string[]
     */
    protected $mods = [];

    /**
     * A list of methods protected by admin permissions.
     *
     * @var string[]
     */
    protected $admins = [];

    /**
     * Create a new instance.
     *
     * @return void
     */
    public function __construct()
    {
        if ($this->users) {
            $this->middleware(User::class, ['only' => $this->users]);
        }

        if ($this->mods) {
            $this->middleware(Mod::class, ['only' => $this->mods]);
        }

        if ($this->admins) {
            $this->middleware(Admin::class, ['only' => $this->admins]);
        }
    }

    /**
     * Set the permission.
     *
     * @param string $action
     * @param string $permission
     *
     * @return void
     */
    protected function setPermission($action, $permission)
    {
        $this->{$permission.'s'}[] = $action;
    }

    /**
     * Set the permissions.
     *
     * @param string[] $permissions
{'fraction_non_alphanumeric': 0.1261558784676354, 'fraction_numerical': 0.005284015852047556, 'mean_word_length': 2.6141607000795544, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 38, 'https://': 2, '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': '2640024', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1284, 'n_words': 400}