/** * Dispatch a nested URL * * @param $uri * * @return string */ protected function _dispatchNestedUrl($uri) { // if url path is empty, return unchanged if (empty($uri[1])) { return $uri[0]; } $prefix = ''; list($path, $append) = Strings::explode('?', $uri[1], [$uri[1], null], 2); //Take a root link as it comes if (!Strings::startsWith($path, '/')) { $relPath = $this->_assetManager->getRelativePath(); if (Strings::startsWith($path, '../')) { $max = count($relPath); $depth = substr_count($path, '../'); $path = substr($path, $depth * 3); if ($depth > 0 && $depth < $max) { $rel = array_slice($relPath, 0, $depth); $prefix = implode('/', $rel); } } else { $prefix = implode('/', $relPath); } } $path = ltrim($path, '/'); $url = $this->_assetManager->getResourceUri(Path::buildUnix($prefix, $path)); if (empty($url)) { return $uri[0]; } if (!empty($append)) { return "url('{$url}?{$append}')"; } return "url('{$url}')"; }
public static function escape($string, $arrayGlue = ' ') { if ($string instanceof SafeHtml) { return $string; } else { if ($string instanceof ISafeHtmlProducer) { $result = $string->produceSafeHTML(); if ($result instanceof SafeHtml) { return $result; } else { if (is_array($result)) { return self::escape($result, $arrayGlue); } else { if ($result instanceof ISafeHtmlProducer) { return self::escape($result, $arrayGlue); } else { try { Strings::stringable($result); return self::escape((string) $result); } catch (\Exception $ex) { $class = get_class($string); throw new \Exception("Object (of class '{$class}') implements " . "ISafeHTMLProducer but did not return anything " . "renderable from produceSafeHTML()."); } } } } } else { if (is_array($string)) { return implode($arrayGlue, array_map(['\\Packaged\\Glimpse\\Core\\SafeHtml', 'escape'], $string)); } } } return Strings::escape($string); }
public function orderBy($fields) { /** * @var $this IStatement */ $orderClause = new OrderByClause(); if (is_array($fields)) { foreach ($fields as $field => $order) { if (Strings::containsAny($order, ['asc', 'desc'], false)) { $orderClause->addField($field, $order); } else { $orderClause->addField($order); } } } else { if (func_num_args() > 1) { foreach (func_get_args() as $field) { $orderClause->addField($field); } } else { $orderClause->addField($fields); } } $this->addClause($orderClause); return $this; }
public function __construct($uri, $content = null, $selector = '#pagelet-data') { parent::__construct($uri, $content); $this->_tag = 'a'; $this->setAttribute('data-uri', $uri); if (!Strings::containsAny($selector, ['#', '.', ' '])) { $selector = '#' . $selector; } $this->setAttribute('data-target', $selector); }
public function setPropertyArray($properties) { $this->_properties = []; foreach ($properties as $property) { if (Strings::containsAny($property, ['"', "'", ')'])) { $this->_properties[] = $property; } else { $this->_properties[] = FieldExpression::create($property); } } return $this; }
/** * Retrieve the table name for this DAO * * @return string */ public function getTableName() { if ($this->_tableName === null) { $class = get_called_class(); $ns = Objects::getNamespace($class); $dirs = $this->getTableNameExcludeDirs(); foreach ($dirs as $dir) { $ns = ltrim(Strings::offset($ns, $dir), '\\'); } $this->_tableName = trim(Inflector::tableize(implode('_', [Strings::stringToUnderScore($ns), Inflector::pluralize(Objects::classShortname($class))])), '_ '); $this->_tableName = str_replace('__', '_', $this->_tableName); } return $this->_tableName; }
/** * @return ISafeHtmlProducer */ public function render() { $output = new Div(); $groups = $this->getMethods(); foreach ($groups as $group => $methods) { $output->appendContent(Div::create(new HeadingOne(Strings::titleize($group)))->addClass('content-container')); foreach ($methods as $method) { $reflect = new \ReflectionMethod($this, $method); $parsed = DocBlockParser::fromMethod($this, $method); $code = $this->_getCode($reflect); $id = Strings::randomString(4); $toggledCode = new Div(); $toggledCode->appendContent(new HeadingFour((new Link('#', Strings::titleize($method)))->setAttribute('onclick', '$(\'#code-' . $id . '\')' . '.toggleClass(\'' . Ui::HIDE . '\');' . 'return false;'))); $code = new SafeHtml(str_replace('<span style="color: #0000BB"><?php </span>', '', highlight_string('<?php ' . $code, true))); $toggledCode->appendContent(Div::create()->appendContent(HtmlTag::createTag('pre', [], $code))->addClass(Ui::HIDE)->setId('code-' . $id)); $methRow = Div::create()->addClass('content-container'); $methRow->appendContent($toggledCode); $methRow->appendContent(new Paragraph($parsed->getSummary())); $methRow->appendContent($this->{$method}()); $output->appendContent($methRow); } } return $output; }
/** * Customer Subscription Status * * @param mixed $default * @param bool $trim Trim Value * * @return string */ public function getSubscriptionType($default = null, $trim = true) { $value = $this->_subscriptionType ?: $default; return $trim ? Strings::ntrim($value) : $value; }
/** * @param mixed $default * @param bool $trim Trim Value * * @return string */ public function getInvoiceStatus($default = null, $trim = true) { $value = Objects::property($this->_getResultJson(), 'invoiceStatus', $default); return $trim ? Strings::ntrim($value) : $value; }
use Fortifi\Sdk\Fortifi; use Packaged\Helpers\Strings; //Create a fortifi instance $fortifi = Fortifi::getInstance('ORG:DC:1448:6f535', 'ZGVmZWViNDI3-SDKT-MDNiOTc0OTVh', 'MjgyYjRmMzdhODM0Y2U2YmZhYTM5NTYyY2I1OWQ2'); $ref = Strings::randomString(3); var_dump(Strings::jsonPretty($fortifi->visitor('VIS:' . $ref)->triggerAction('FID:COMP:1427472077:4b37c88345e0', 'lead', 'LEAD-' . $ref))); //Create a new customer $customer = $fortifi->customer()->create('*****@*****.**', 'John', 'Smith', '036486346', 'TEST-' . $ref); //Customer FID applied to this customer object, for future requests do: $customer = $fortifi->customer('CustomerFid'); //Get any pixels required for this visitor $pixels = $fortifi->visitor()->getPixels(); if ($pixels) { foreach ($pixels as $pixel) { //Output $pixel to page var_dump(Strings::jsonPretty($pixel)); } } //Mark Customer Conversion to paid account $customer->purchase('ORDER-' . $ref, 12.98, ['product_id' => 'SUBSCRIP', 'product_name' => 'Account Subscription']); //Customer purchased an account addon (upsell) $customer->purchaseUpsell('UPS-' . $ref, 1.95, ['products' => ['PREMIUM_SUPPORT']]); //Mark Renewals $customer->renewed('RENEWAL-' . $ref, 15.98, ['renewal_count' => 1]); $customer->renewed('RENEWAL-' . $ref, 15.98, ['renewal_count' => 2]); //Customer cancelled their renewal $customer->cancel('RENEWAL-' . $ref); //Customer did a chargeback on their first renewal $customer->chargeback('RENEWAL-' . $ref, 15.98, ['chargeback_id' => 'FKJDK-EWKH-4438-FJ']); //Account picked up as credit card fraud from chargeback investifation $customer->markAsFraud('ORDER-' . $ref, 12.98, ['reason' => 'Credit Card Fraud']);
/** * Coinbase checkout ID * * @param mixed $default * @param bool $trim Trim Value * * @return string */ public function getCheckoutID($default = null, $trim = true) { $value = Objects::property($this->_getResultJson(), 'checkoutID', $default); return $trim ? Strings::ntrim($value) : $value; }
/** * Client IP Address * * @param mixed $default * @param bool $trim Trim Value * * @return string */ public function getClientIp($default = null, $trim = true) { $value = $this->_clientIp ?: $default; return $trim ? Strings::ntrim($value) : $value; }
/** * Discription * * @param mixed $default * @param bool $trim Trim Value * * @return string */ public function getDescription($default = null, $trim = true) { $value = Objects::property($this->_getResultJson(), 'description', $default); return $trim ? Strings::ntrim($value) : $value; }
/** * @param array $params * * @return array * * @throws SickBeardException */ protected function _request($params) { if ($this->_debug) { $params['debug'] = 1; } if ($this->_profile) { $params['profile'] = 1; } if ($this->_help) { $params['help'] = 1; } if ($this->_callback) { $params['callback'] = $this->_callback; } $url = $this->_url . '/api/' . $this->_apiKey; $response = Curl::get($url, $params)->run(); if ($response->getHttpCode() != 200) { throw new SickBeardException('Invalid response'); } $contentType = $response->getContentType(); if (Strings::contains($contentType, 'json', false)) { $array = $response->getJson(); if (isset($array['result']) && $array['result'] != 'success') { throw new SickBeardException($array['message']); } return $array['data']; } else { header('Content-Type: ' . $contentType); return $response->getOutput(); } }
/** * Explode a string, filling the remainder with provided defaults. * * @param string $delimiter The boundary string * @param string $string The input string. * @param array|mixed $defaults Array to return, with replacements made, * or a padding value * @param int|null $limit Passed through to the initial explode * * @return array * * @deprecated */ function exploded($delimiter, $string, $defaults = null, $limit = null) { return \Packaged\Helpers\Strings::explode($delimiter, $string, $defaults, $limit); }
/** * Account Status * * @param mixed $default * @param bool $trim Trim Value * * @return string */ public function getAccountStatus($default = null, $trim = true) { $value = $this->_accountStatus ?: $default; return $trim ? Strings::ntrim($value) : $value; }
/** * @param mixed $default * @param bool $trim Trim Value * * @return string */ public function getToken($default = null, $trim = true) { $value = $this->_token ?: $default; return $trim ? Strings::ntrim($value) : $value; }
function assert_stringlike($parameter) { \Packaged\Helpers\Strings::stringable($parameter); }
/** * @param mixed $default * @param bool $trim Trim Value * * @return string */ public function getCommissionCurrency($default = null, $trim = true) { $value = Objects::property($this->_getResultJson(), 'commissionCurrency', $default); return $trim ? Strings::ntrim($value) : $value; }
public static function getValue($key) { $key = 'static::' . $key; if (defined($key)) { $value = constant($key); return Strings::splitOnCamelCase($value); } else { return null; } }
/** * Prepare the form */ protected function _boot() { $formDoc = DocBlockParser::fromObject($this->getDataObject()); $labelPosition = FormElement::LABEL_BEFORE; $defaultTags = []; foreach ($formDoc->getTags() as $tag => $values) { foreach ($values as $value) { if (Strings::startsWith($tag, 'element', false)) { $defaultTags[substr($tag, 7)] = $value; } } } foreach ($this->_processPublicProperties() as $property) { if (isset($this->_elements[$property])) { continue; } static::$_propDocBlocks[$this->_calledClass][$property] = $docblock = DocBlockParser::fromProperty($this->getDataObject(), $property); //Setup the type $type = $docblock->getTagFailover(["inputType", "type", "input"]); if ($type === null) { $type = FormElement::calculateType($property); } //Setup the label $label = $docblock->getTag("label"); if ($label === null) { $label = Strings::humanize($property); } $element = new FormElement($this, $property, $type, $label, $labelPosition); foreach ($defaultTags as $tag => $value) { $element->processDocBlockTag($tag, $value); } $element->setDataObject($this->getDataObject(), $property); $this->_aliases[$element->getName()] = $property; foreach ($docblock->getTags() as $tag => $values) { foreach ($values as $value) { $element->processDocBlockTag($tag, $value); } } $this->_elements[$property] = $element; } if ($this->_enableCsrf) { $this->_buildCsrf(); } else { $this->getElement($this->_csrfField)->setRenderer(new FormElementRenderer('')); } }
/** * Is Dispatch responsible for the incoming request * * @param Request $request * * @return bool */ public function isDispatchRequest(Request $request) { $runOn = $this->_config->getItem('run_on', 'path'); switch ($runOn) { case 'path': $match = $this->_config->getItem('run_match', 'res'); return Strings::startsWith($request->getPathInfo() . '/', "/{$match}/"); case 'subdomain': $matchCfg = $this->_config->getItem('run_match', 'static.,assets.'); $subDomains = ValueAs::arr($matchCfg, ['static.']); return Strings::startsWithAny($request->getHost(), $subDomains); case 'domain': $matchCfg = $this->_config->getItem('run_match', null); $domains = ValueAs::arr($matchCfg, []); return Strings::endsWithAny($request->getHttpHost(), $domains, false); } return false; }
/** * Postal/Zip Code of the card * * @param mixed $default * @param bool $trim Trim Value * * @return string */ public function getAddressPostal($default = null, $trim = true) { $value = $this->_addressPostal ?: $default; return $trim ? Strings::ntrim($value) : $value; }
/** * @param mixed $default * @param bool $trim Trim Value * * @return string */ public function getMaxQuantity($default = null, $trim = true) { $value = Objects::property($this->_getResultJson(), 'maxQuantity', $default); return $trim ? Strings::ntrim($value) : $value; }
public function getHash() { return md5(Strings::concat($this->property, $this->negate, $this->matchType, json_encode($this->value))); }
public static function getFileName($value) { return Strings::urlize(static::getDisplayValue($value) . '.html'); }
/** * @param PdoException $e * * @return bool */ private function _isRecoverableException(PdoException $e) { $code = $e->getPrevious()->getCode(); if ($code === 0 || Strings::startsWith($code, 42)) { return false; } return true; }
/** * If known, the Fortifi event ID for this visitors action * * @param mixed $default * @param bool $trim Trim Value * * @return string */ public function getEventId($default = null, $trim = true) { $value = $this->_eventId ?: $default; return $trim ? Strings::ntrim($value) : $value; }
/** * Term Type * * @param mixed $default * @param bool $trim Trim Value * * @return string */ public function getTermType($default = null, $trim = true) { $value = Objects::property($this->_getResultJson(), 'termType', $default); return $trim ? Strings::ntrim($value) : $value; }
/** * Retrieve the name for this endpoint * * @return string */ public function getName() { return Strings::titleize(Objects::classShortname(get_called_class())); }