<commit_before><?php
namespace {

    use Apatis\ArrayStorage\CollectionFetch;
    use Pentagonal\PhPass\PasswordHash;
    use PentagonalProject\App\Rest\Abstracts\ResponseGeneratorAbstract;
    use PentagonalProject\App\Rest\Generator\Response\Json;
    use PentagonalProject\App\Rest\Generator\ResponseStandard;
    use PentagonalProject\App\Rest\Util\Domain\Verify;
    use PentagonalProject\Model\Database\User;
    use Psr\Http\Message\ResponseInterface;
    use Psr\Http\Message\ServerRequestInterface;

    $this->post('/users', function (ServerRequestInterface $request, ResponseInterface $response) {
        /**
         * @var CollectionFetch $collectionFetch that use ArrayAccess
         * that mean acess data just need to pass by array bracket
         *
         * -> $collectionFetch[keyName]
         */
        $collectionFetch = new CollectionFetch((array) $request->getParsedBody());
        try {
            // data to check
            $check = [
                'first_name',
                'last_name',
                'username',
                'email',
                'password'
            ];

            $domain = new Verify();
            foreach ($check as $toCheck) {
                // do check email
                if ($toCheck === 'email') {
                    // doing validate email with real valid email address
                    $email = $domain->validateEmail(
                        (string) $collectionFetch['email']
                    );
                    if (!$email) {
                        throw new InvalidArgumentException(
                            "Invalid email address",
                            E_USER_ERROR
                        );
                    }
                    // set fix email
                    $collectionFetch->set('email', $email);
                    continue;
                }

                // validate data that must be string
                // even though exists or not it will be check
                if (!is_string($collectionFetch[$toCheck])) {
                    throw new InvalidArgumentException(
                        sprintf(
                            "Invalid %s",
                            ucwords(str_replace('_', ' ', $toCheck))
                        )
                    );
                }

                //  doing next validation
                // ..................
            }

            // Instantiate password hash
            $passwordHash = new PasswordHash();
            $user = new User([
                'first_name' => $collectionFetch['first_name'],
                'last_name' => $collectionFetch['last_name'],
                'username' => $collectionFetch['username'],
                'email' => $collectionFetch['email'],
                'password' => $passwordHash->hash(sha1($collectionFetch['password'])),
                /**
                 * @uses microtime() has enough to generate very unique data double float
                 */
                'private_key' => hash('sha512', microtime())
            ]);

            $user->saveOrFail();

            /**
             * Modify response header
             *
             * @var string $userId
             * @var ResponseInterface $response
             */
            $response = $response->withHeader(
                'Location',
                (string)$request->getUri()->withPath('users/' . $userId)
            );
            return ResponseStandard::withData(
                $request,
                // response & data can pass here to prevent more memory usage on variable
                $response->withStatus(201),
                $user->getKey(),
                Json::class,
                /**
                 * magic additional arguments for @uses ResponseGeneratorAbstract::serve()
                 */
                true
            );
        } catch (Exception $e) {
            return ResponseStandard::withData(
                $request,
                $response->withStatus(500),
                $e,
                Json::class, // or just put null as value
                true // add pretty print on Json Generator
            );
        }<commit_msg>Change Status Code -> Add Simpler Way for routes (Example)<commit_after><?php
namespace {

    use Apatis\ArrayStorage\CollectionFetch;
    use Pentagonal\PhPass\PasswordHash;
    use PentagonalProject\App\Rest\Abstracts\ResponseGeneratorAbstract;
    use PentagonalProject\App\Rest\Generator\Response\Json;
    use PentagonalProject\App\Rest\Generator\ResponseStandard;
    use PentagonalProject\App\Rest\Util\Domain\Verify;
    use PentagonalProject\Model\Database\User;
    use Psr\Http\Message\ResponseInterface;
    use Psr\Http\Message\ServerRequestInterface;

    $this->post('/users', function (ServerRequestInterface $request, ResponseInterface $response) {
        /**
         * @var CollectionFetch $collectionFetch that use ArrayAccess
         * that mean acess data just need to pass by array bracket
         *
         * -> $collectionFetch[keyName]
         */
        $collectionFetch = new CollectionFetch((array) $request->getParsedBody());
        try {
            // data to check
            $check = [
                'first_name',
                'last_name',
                'username',
                'email',
                'password'
            ];

            $domain = new Verify();
            foreach ($check as $toCheck) {
                // do check email
                if ($toCheck === 'email') {
                    // doing validate email with real valid email address
                    $email = $domain->validateEmail(
                        (string) $collectionFetch['email']
                    );
                    if (!$email) {
                        throw new InvalidArgumentException(
                            "Invalid email address",
                            E_USER_ERROR
                        );
                    }
                    // set fix email
                    $collectionFetch->set('email', $email);
                    continue;
                }

                // validate data that must be string
                // even though exists or not it will be check
                if (!is_string($collectionFetch[$toCheck])) {
                    throw new InvalidArgumentException(
                        sprintf(
                            "Invalid %s",
                            ucwords(str_replace('_', ' ', $toCheck))
                        )
                    );
                }

                //  doing next validation
                // ..................
            }

            // Instantiate password hash
            $passwordHash = new PasswordHash();
            $user = new User([
                'first_name' => $collectionFetch['first_name'],
                'last_name' => $collectionFetch['last_name'],
                'username' => $collectionFetch['username'],
                'email' => $collectionFetch['email'],
                'password' => $password<PASSWORD>(sha1($collectionFetch['password'])),
                /**
                 * @uses microtime() has enough to generate very unique data double float
                 */
                'private_key' => hash('sha512', microtime())
            ]);

            $user->saveOrFail();

            /**
             * Modify response header
             *
             * @var string $userId
             * @var ResponseInterface $response
             */
            $response = $response->withHeader(
                'Location',
                (string)$request->getUri()->withPath('users/' . $userId)
            );
            return ResponseStandard::withData(
                $request,
                // response & data can pass here to prevent more memory usage on variable
                $response->withStatus(201),
                $user->getKey(),
                Json::class,
                /**
                 * magic additional arguments for @uses ResponseGeneratorAbstract::serve()
                 */
                true
            );
        } catch (Exception $e) {
            return ResponseStandard::withData(
                $request,
                $response->withStatus(406),
                $e,
                Json::class, // or just put null as value
                true // add pretty print on Json Generator
            );
        }
{'fraction_non_alphanumeric': 0.10314167160640189, 'fraction_numerical': 0.0023710729104919974, 'mean_word_length': 1.2544094067343667, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 42, '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': '949245', 'n_tokens_mistral': 1929, 'n_tokens_neox': 1802, 'n_words': 450}