<commit_before><?php

namespace Controllers;

use Models\User as User;

/**
 * HomeController
 */
class UsersController extends Controller
{

    public function getUser($userId)
    {
        if ($userId === 'me')
            $userId = $_SESSION['id'];

        if (!empty($userId))
            $data = User::byId($userId)->getAll();
        else
            $data = [];

        $status = 'success';
        return json_encode(compact('status', 'data'));
    }
}
<commit_msg>Added error message on userId = null<commit_after><?php

namespace Controllers;

use Models\User as User;

/**
 * HomeController
 */
class UsersController extends Controller
{

    /**
     * Get the user's id, name and e-mail.
     *
     * @param int $userId
     * @return string
     */
    public function getUser(int $userId): string
    {
        if ($userId === 'me')
            $userId = $_SESSION['id'];

        if (!empty($userId)) {
            $status   = 'success';
            $data     = User::byId($userId)->getAll();
            $response = compact('status', 'data');
        } else {
            $status   = "error";
            $error    = "User id cannot be empty.";
            $response = compact('status', 'error');
        }

        return json_encode($response);
    }
}

{'fraction_non_alphanumeric': 0.15035238841033674, 'fraction_numerical': 0.0, 'mean_word_length': 2.0, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6935856', 'n_tokens_mistral': 365, 'n_tokens_neox': 370, 'n_words': 94}