KLIPFOLIO BUG!
When value of ClientResource resource is falsey (0), Klipfolio gives an API error.

$data looks like [
['name' => '', 'value' => '']...
]

@param $data
@return mixed
963990
public function withoutFalseyValues($data)
    {
        for ($i = 0; $i < count($data[ClientResource::FIELD_RESOURCES]); $i++) {
            if (!$data[ClientResource::FIELD_RESOURCES][$i]['value']) {
                unset($data[ClientResource::FIELD_RESOURCES][$i]);
            }
        }

        // Resort array
        $data[ClientResource::FIELD_RESOURCES] = array_values($data[ClientResource::FIELD_RESOURCES]);

        return $data;
    }
1039359
public function getTemplateData($data = [])
    {
        // generate fields
        $fillableColumns = $this->schemaParser->getFillableFields($data['TABLE_NAME']);
        logger($fillableColumns);

        $faker = Factory::create();

        $fieldStr = [];
        foreach ($fillableColumns as $column) {
            try {
                if ($column['field'] === 'password') {
                    $func = 'bcrypt(str_random(10))';
                } else {
                    $faker->getFormatter($column['field']);

                    $func = '$faker->'.$column['field'];
                }
            } catch (\Exception $e) {
                logger($column['type']);
                switch ($column['type']) {
                    case 'tinyInteger':
                        $func = '$faker->randomNumber(2)';
                        break;
                    case 'smallInteger':
                        $func = '$faker->randomNumber(2)';
                        break;
                    case 'mediumInteger':
                        $func = '$faker->randomNumber(4)';
                        break;
                    case 'integer':
                        $func = '$faker->randomNumber(8)';
                        break;
                    case 'char':
                    case 'string':
                        logger($column['field']);
                        if (isset($column['args']) && !empty($column['args'])) {
                            $max = $column['args'];
                        } else {
                            $max = 100;
                        }
                        $func = "str_random($max)";
                        break;
                    case 'text':
                    case 'boolean':
                        $func = '$faker->'.$column['type'].'()';
                        break;
                    case 'date':
                        $func = '$faker->'.'dateTimeBetween()';
                        break;
                    default:
                        $func = '';
                }
            }

            if (!empty($func)) {
                $fieldStr[] = "'".$column['field']."' => ".$func;
            }
            
        }
        $data['FIELDS'] = implode(",\n\t\t", $fieldStr);

        return $data;
    }
384876
protected function getValuesForValidation($data = null)
  {
    $out = array();
    foreach ($this->fields as $field => $el) {
      $out[$field] = !is_null($data)
        ? isset($data[$field]) ? $data[$field] : false
        : $this->getValueFromRequest($field);
    }

    return $out;
  }
985976
protected function getRealValues(array $data) {
        $maps = Arr::getRealType($this->modelName);
        return empty($maps) ? $data : Arr::toRealArr($data, $maps);
    }
138390
public static function getJSObject(...$data)
    {
        $quote = array_pop($data);

        if (!is_bool($quote)) {
            $data[] = $quote;
            $quote  = false;
        }

        if (count($data) > 1) {
            $result = [];

            foreach ($data as $array) {
                $result = static::mergeOptions($result, $array);
            }
        } else {
            $result = $data[0];
        }

        return static::getAsset()->getJSObject($result, $quote);
    }
1152445
protected function getFieldValueFromData($data, array $options)
    {
        $fieldValue = $this->config->getProvider('fieldValue');
        $fieldValue = new $fieldValue($this->config);
        $result = $fieldValue->provide($data, $options);

        return $result;
    }
854669
protected function convertToResource($data)
    {
        return Location::make($this->client, $this->library, $data->code)
            ->init($data);
    }
955825
protected function getDefaultPayload($data)
    {
        $payload = [
            'payload' => base64_encode($data),
            'last_activity' => $this->currentTime(),
        ];

        if (! $this->container) {
            return $payload;
        }

        return tap($payload, function (&$payload) {
            $this->addUserInformation($payload)
                 ->addRequestInformation($payload);
        });
    }
988597
public function outputError($data)
    {
        $defaults = [
            'level' => 0,
            'error' => 0,
            'code' => 0,
            'description' => '',
            'file' => '',
            'line' => 0,
            'context' => [],
            'start' => 2,
        ];
        $data += $defaults;

        $files = static::trace(['start' => $data['start'], 'format' => 'points']);
        $code = '';
        $file = null;
        if (isset($files[0]['file'])) {
            $file = $files[0];
        } elseif (isset($files[1]['file'])) {
            $file = $files[1];
        }
        if ($file) {
            $code = static::excerpt($file['file'], $file['line'], 1);
        }
        $trace = static::trace(['start' => $data['start'], 'depth' => '20']);
        $insertOpts = ['before' => '{:', 'after' => '}'];
        $context = [];
        $links = [];
        $info = '';

        foreach ((array)$data['context'] as $var => $value) {
            $context[] = "\${$var} = " . static::exportVar($value, 3);
        }

        switch ($this->_outputFormat) {
            case false:
                $this->_data[] = compact('context', 'trace') + $data;

                return;
            case 'log':
                static::log(compact('context', 'trace') + $data);

                return;
        }

        $data['trace'] = $trace;
        $data['id'] = 'cakeErr' . uniqid();
        $tpl = $this->_templates[$this->_outputFormat] + $this->_templates['base'];

        if (isset($tpl['links'])) {
            foreach ($tpl['links'] as $key => $val) {
                $links[$key] = Text::insert($val, $data, $insertOpts);
            }
        }

        if (!empty($tpl['escapeContext'])) {
            $context = h($context);
            $data['description'] = h($data['description']);
        }

        $infoData = compact('code', 'context', 'trace');
        foreach ($infoData as $key => $value) {
            if (empty($value) || !isset($tpl[$key])) {
                continue;
            }
            if (is_array($value)) {
                $value = implode("\n", $value);
            }
            $info .= Text::insert($tpl[$key], [$key => $value] + $data, $insertOpts);
        }
        $links = implode(' ', $links);

        if (isset($tpl['callback']) && is_callable($tpl['callback'])) {
            call_user_func($tpl['callback'], $data, compact('links', 'info'));

            return;
        }
        echo Text::insert($tpl['error'], compact('links', 'info') + $data, $insertOpts);
    }
331915
protected function scopedData($data, /*# string */ $scope)/*# : array */
    {
        if (is_array($data) && isset($data['class'])) {
            $data['scope'] = $scope;
        } else {
            $data = ['class' => $data, 'scope' => $scope];
        }
        return $data;
    }
1256490
public function create(array $data)
    {
        $data = $this->client->post(Inflector::pluralize($this->getResourceName()), [$this->getResourceName() => $data]);

        return $this->fromArray(reset($data));
    }
895200
protected function convertToResource($data)
    {
        return Request::make($this->client, User::make($this->client, $data->user_primary_id), $data->request_id)
            ->init($data);
    }
1073315
public function create(array $data = [])
    {
        $listItem = new ListItem();

        /** Images */
        if (array_key_exists('backdrop_path', $data)) {
            $listItem->setBackdropImage(
                $this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path')
            );
        }

        if (array_key_exists('poster_path', $data)) {
            $listItem->setPosterImage(
                $this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path')
            );
        }

        return $this->hydrate($listItem, $data);
    }
329287
public function set($data)
    {
        $this->error = [];
        $result = null;
        switch ($this->format) {
            case 'nvp':
                parse_str($data, $this->data);
                $result = !empty($this->data);
                break;

            case 'json':
            default:
                $this->data = empty($data) ? [] : (json_decode($data, true) ?: []);
                $result = json_last_error() == JSON_ERROR_NONE;
                if (empty ($result)) {
                    $this->error = [
                        'error' => json_last_error(),
                        'msg'   => json_last_error_msg(),
                    ];
                }
                break;
        }

        return $result;
    }
26762
public static function setDataAttributes($data)
    {
        if(is_array($data) && count($data) > 0)
        {
            $keys = array_keys($data);

            $response = '';
            foreach($keys as $key)
            {
                $response .= ' data-' . $key . '="' . $data[$key] . '"';
            }

            return $response;
        }

        return null;
    }
760850
public function convertFieldValueFromForm($data)
    {
        $country = array();

        // case if multiple is true
        if (is_array($data)) {
            foreach ($data as $countryCode) {
                if (array_key_exists($countryCode, $this->countryData)) {
                    $country[$countryCode] = $this->countryData[$countryCode];
                }
            }
        } else {
            if (array_key_exists($data, $this->countryData)) {
                $country[$data] = $this->countryData[$data];
            }
        }

        return new CountryValue((array) $country);
    }
1367679
protected function &loadFilterData(&$data) {

        if ( empty($this->filterMap) ) {
            return $data;
        }
        $error = null;
        $data = Filter::loadFromModel($data, $this->filterMap, $error);

        if ( $data == false ) {
            WebApplication::getInstance()->getAppError()->setCode(1);
            WebApplication::getInstance()->getAppError()->setMessage($error);
        }
        return $data;
    }