<commit_before><?php
/**
 * Author: <NAME> (<EMAIL>)
 * Website: https://github.com/disono/Laravel-Template & http://www.webmons.com
 * License: Apache 2.0
 */
namespace App\Library\Helpers;

use ElephantIO\Client as Elephant;
use Intervention\Image\Facades\Image;
use LaravelFCM\Facades\FCM;
use LaravelFCM\Message\OptionsBuilder;
use LaravelFCM\Message\PayloadNotificationBuilder;
use LaravelFCM\Message\Topics;

class WBHttp
{
    /**
     * Success JSON response
     *
     * @param array $data
     * @param null $links
     * @param null $pagination
     * @param null $extra
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public static function successJSONResponse($data = [], $links = null, $pagination = null, $extra = null)
    {
        if (is_array($data) || is_string($data) || is_numeric($data)) {
            return response()->json([
                'success' => true,
                'data' => $data,
                'links' => $links,
                'extra' => $extra
            ], 200);
        }

        $data = ($data) ? ((method_exists($data, 'toArray')) ? $data->toArray() : (array)$data) : $data;
        if (!$data) {
            return self::failedJSONResponse('Data not found.', 404);
        }

        if (isset($data['data'])) {<commit_msg>Update on json returns with LengthAwarePaginator<commit_after><?php
/**
 * Author: <NAME> (<EMAIL>)
 * Website: https://github.com/disono/Laravel-Template & http://www.webmons.com
 * License: Apache 2.0
 */
namespace App\Library\Helpers;

use ElephantIO\Client as Elephant;
use Illuminate\Pagination\LengthAwarePaginator;
use Intervention\Image\Facades\Image;
use LaravelFCM\Facades\FCM;
use LaravelFCM\Message\OptionsBuilder;
use LaravelFCM\Message\PayloadNotificationBuilder;
use LaravelFCM\Message\Topics;

class WBHttp
{
    /**
     * Success JSON response
     *
     * @param array $data
     * @param null $links
     * @param null $pagination
     * @param null $extra
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public static function successJSONResponse($data = [], $links = null, $pagination = null, $extra = null)
    {
        if (is_array($data) || is_string($data) || is_numeric($data) || !$data instanceof LengthAwarePaginator) {
            return response()->json([
                'success' => true,
                'data' => $data,
                'links' => $links,
                'extra' => $extra
            ], 200);
        }

        $data = ($data) ? ((method_exists($data, 'toArray')) ? $data->toArray() : (array)$data) : $data;
        if (!$data) {
            return self::failedJSONResponse('Data not found.', 404);
        }

        if (isset($data['data'])) {
{'fraction_non_alphanumeric': 0.1518285925378648, 'fraction_numerical': 0.005910602142593277, 'mean_word_length': 2.5631578947368423, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5604324', 'n_tokens_mistral': 842, 'n_tokens_neox': 831, 'n_words': 182}