<commit_before><?php

namespace Zhiyi\Plus\Http\Controllers\Admin;

use Illuminate\Http\Request;
use Zhiyi\Plus\Http\Controllers\Controller;
use Zhiyi\Plus\Models\User;

class UserController extends Controller
{
    public function users(Request $request)
    {
        $sort = $request->query('sort');
        $userId = $request->query('user_id');
        $email = $request->query('email');
        $name = $request->query('name');
        $phone = $request->query('phone');
        $role = $request->query('role');

        $builder = with(new User)->newQuery();

        // user id
        if ($userId && $user = $builder->where('id', $userId)->get()) {
            return response()->json($user);
        }

        foreach ([
            'email' => [
                'operator' => 'like',
                'value' => sprintf('%%%s%%', $email),
                'condition' => boolval($email)
            ],
            'name' => [
                'operator' => 'like',
                'value' => sprintf('%%%s%%', $name),
                'condition' => boolval($name)
            ],
            'phone' => [
                'operator' => 'like',
                'value' => sprintf('%%%s%%', $phone),
                'condition' => boolval($phone)
            ]
        ] as $key => $data) {
            if ($data['condition']) {
                $builder = $builder->where($key, $data['operator'], $data['value']);
            }
        }

        // build sort.
        $builder = $builder->orderBy('id', ($sort === 'down' ? 'desc' : 'asc'));

        $role && $builder = $builder->whereHas('roles', function ($query) use ($role) {
            $query->where('id', $role);
        });

        return response()->json($builder->get());
    }
}<commit_msg>Apply fixes from StyleCI<commit_after><?php

namespace Zhiyi\Plus\Http\Controllers\Admin;

use Illuminate\Http\Request;
use Zhiyi\Plus\Http\Controllers\Controller;
use Zhiyi\Plus\Models\User;

class UserController extends Controller
{
    public function users(Request $request)
    {
        $sort = $request->query('sort');
        $userId = $request->query('user_id');
        $email = $request->query('email');
        $name = $request->query('name');
        $phone = $request->query('phone');
        $role = $request->query('role');

        $builder = with(new User())->newQuery();

        // user id
        if ($userId && $user = $builder->where('id', $userId)->get()) {
            return response()->json($user);
        }

        foreach ([
            'email' => [
                'operator' => 'like',
                'value' => sprintf('%%%s%%', $email),
                'condition' => boolval($email),
            ],
            'name' => [
                'operator' => 'like',
                'value' => sprintf('%%%s%%', $name),
                'condition' => boolval($name),
            ],
            'phone' => [
                'operator' => 'like',
                'value' => sprintf('%%%s%%', $phone),
                'condition' => boolval($phone),
            ],
        ] as $key => $data) {
            if ($data['condition']) {
                $builder = $builder->where($key, $data['operator'], $data['value']);
            }
        }

        // build sort.
        $builder = $builder->orderBy('id', ($sort === 'down' ? 'desc' : 'asc'));

        $role && $builder = $builder->whereHas('roles', function ($query) use ($role) {
            $query->where('id', $role);
        });

        return response()->json($builder->get());
    }
}
{'fraction_non_alphanumeric': 0.2010761823845936, 'fraction_numerical': 0.0, 'mean_word_length': 1.8256, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, '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': '3823737', 'n_tokens_mistral': 1025, 'n_tokens_neox': 1004, 'n_words': 191}