$value) { if (is_array($value)) { $content .= "'" . $key . "' => ["; $content .= $this->toPHP($value); $content .= "],\n"; } else { $content .= "'" . $key . "' => '" . str_replace("'", "\'", $value) . "',\n"; } } return $content; } /** * Set options for API Request * * @param string $key - Key * @param mixed $value - Value */ public function set($key, $value = false) { if (!$this->convert) { $this->convert = new stdClass(); } if (is_array($key)) { foreach ($key as $attr => $value) { $this->convert->$attr = $value; } } else { $this->convert->$key = $value; } } /** * Convert Template */ public function convert() { $data = !empty($this->convert->data) ? $this->convert->data : array(); $file = 'toPHP($data); $file .= '];' . PHP_EOL; $file .= 'return $template;' . PHP_EOL; $file .= '}'; if ($file) { $response['file'] = base64_encode($file); } else { $response['error'] = __("Something went wrong!", "e2pdf"); } return $response; } }