<commit_before><?php

namespace App\GoVoyage\Library;

use \Illuminate\Support\Collection;

use \Carbon\Carbon;

use \App\GoVoyage\Library\SchipholApi;
use \App\GoVoyage\Library\TransaviaApi;
use \App\GoVoyage\Library\KLMApi;

use Storage;

use App\Airport;
use App\CacheWeather;

class Flights
{
    public static function search(
        Carbon $startDate = null,
        Carbon $endDate = null,
        int $maxBudget = null,
        int $passengers = null,
        int $temperature = null
    ) : Collection {
        // Almost all values are optional, check which are not set and give them their default values
        $startDate = ($startDate === null) ? Carbon::now() : $startDate;
        $endDate = ($endDate === null) ? Carbon::now()->addYear(1) : $endDate;
        $maxBudget = ($maxBudget === null) ? 8000 : $maxBudget;
        $passengers = ($passengers === null) ? 1 : $passengers;

        // Fix request caching for improved speeds
        $hash = sha1($startDate->format('d-m-Y') . $endDate->format('d-m-Y') . $maxBudget . $passengers . $temperature);

        if (Storage::exists('search/' . $hash)) {
            return collect(Storage::get('search/' . $hash));
        }

        // Initialize the API's
        $klm = new KLMApi(env('KLM_API_ENDPOINT'), env('KLM_API_ID'), env('KLM_API_KEY'));<commit_msg>fix for cache returning json strings instead of the expected array<commit_after><?php

namespace App\GoVoyage\Library;

use \Illuminate\Support\Collection;

use \Carbon\Carbon;

use \App\GoVoyage\Library\SchipholApi;
use \App\GoVoyage\Library\TransaviaApi;
use \App\GoVoyage\Library\KLMApi;

use Storage;

use App\Airport;
use App\CacheWeather;

class Flights
{
    public static function search(
        Carbon $startDate = null,
        Carbon $endDate = null,
        int $maxBudget = null,
        int $passengers = null,
        int $temperature = null
    ) : Collection {
        // Almost all values are optional, check which are not set and give them their default values
        $startDate = ($startDate === null) ? Carbon::now() : $startDate;
        $endDate = ($endDate === null) ? Carbon::now()->addYear(1) : $endDate;
        $maxBudget = ($maxBudget === null) ? 8000 : $maxBudget;
        $passengers = ($passengers === null) ? 1 : $passengers;

        // Fix request caching for improved speeds
        $hash = sha1($startDate->format('d-m-Y') . $endDate->format('d-m-Y') . $maxBudget . $passengers . $temperature);

        if (Storage::exists('search/' . $hash)) {
            return collect(json_decode(Storage::get('search/' . $hash)));
        }

        // Initialize the API's
        $klm = new KLMApi(env('KLM_API_ENDPOINT'), env('KLM_API_ID'), env('KLM_API_KEY'));
{'fraction_non_alphanumeric': 0.14495952906548934, 'fraction_numerical': 0.0051508462104488595, 'mean_word_length': 2.9348769898697538, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2247030', 'n_tokens_mistral': 899, 'n_tokens_neox': 862, 'n_words': 215}