<commit_before><?php

namespace smartystreets\api\us_zipcode;

require_once(dirname(dirname(dirname(__FILE__))) . '/api/Sender.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/api/Serializer.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/api/Request.php');
require_once('Batch.php');
use smartystreets\api\Sender;
use smartystreets\api\Serializer;
use smartystreets\api\Request;

class Client {
    private $urlPrefix,
            $sender,
            $serializer;

    public function __construct($urlPrefix, Sender $sender, Serializer $serializer = null) {
        $this->urlPrefix = $urlPrefix;
        $this->sender = $sender;
        $this->serializer = $serializer;
    }

    public function sendLookup(Lookup $lookup) {
        $batch = new Batch();
        $batch->add($lookup);
        $this->sendBatch($batch);
    }

    public function sendBatch(Batch $batch) {
        $request = new Request($this->urlPrefix);

        if ($batch->size() == 0)
            return;

        if ($batch->size() == 1)
            $this->populateQueryString($batch->getLookupByIndex(0), $request);
        else
            $request->setPayload($this->serializer->serialize($batch->getAllLookups(), Lookup::class));

        $response = $this->sender->send($request);

        $results = $this->serializer->deserialize($response->getPayload(), Result::class);
        if ($results == null) {
            $results = array();
            $results[0] = new Result();
        }

        $this->assignResultsToLookups($batch, $results);
    }

    private function populateQueryString(Lookup $lookup, Request $request) {
        $request->setParameter("input_id", $lookup->getInputId());
        $request->setParameter("city", $lookup->getCity());
        $request->setParameter("state", $lookup->getState());
        $request->setParameter("zipcode", $lookup->getZipCode());
    }

    private function assignResultsToLookups(Batch $batch, $results) {<commit_msg>Fixed calls to the serializer.<commit_after><?php

namespace smartystreets\api\us_zipcode;

require_once(dirname(dirname(dirname(__FILE__))) . '/api/Sender.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/api/Serializer.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/api/Request.php');
require_once('Batch.php');
use smartystreets\api\Sender;
use smartystreets\api\Serializer;
use smartystreets\api\Request;

class Client {
    private $urlPrefix,
            $sender,
            $serializer;

    public function __construct($urlPrefix, Sender $sender, Serializer $serializer = null) {
        $this->urlPrefix = $urlPrefix;
        $this->sender = $sender;
        $this->serializer = $serializer;
    }

    public function sendLookup(Lookup $lookup) {
        $batch = new Batch();
        $batch->add($lookup);
        $this->sendBatch($batch);
    }

    public function sendBatch(Batch $batch) {
        $request = new Request($this->urlPrefix);

        if ($batch->size() == 0)
            return;

        if ($batch->size() == 1)
            $this->populateQueryString($batch->getLookupByIndex(0), $request);
        else
            $request->setPayload($this->serializer->serialize($batch->getAllLookups()));

        $response = $this->sender->send($request);

        $results = $this->serializer->deserialize($response->getPayload());
        if ($results == null) {
            $results = array();
            $results[0] = new Result();
        }

        $this->assignResultsToLookups($batch, $results);
    }

    private function populateQueryString(Lookup $lookup, Request $request) {
        $request->setParameter("input_id", $lookup->getInputId());
        $request->setParameter("city", $lookup->getCity());
        $request->setParameter("state", $lookup->getState());
        $request->setParameter("zipcode", $lookup->getZipCode());
    }

    private function assignResultsToLookups(Batch $batch, $results) {
{'fraction_non_alphanumeric': 0.1607006854531607, 'fraction_numerical': 0.002030972328002031, 'mean_word_length': 3.236559139784946, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 59, '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': '6191674', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1110, 'n_words': 198}