本文整理汇总了PHP中zibo\library\String类的典型用法代码示例。如果您正苦于以下问题:PHP String类的具体用法?PHP String怎么用?PHP String使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructs a new XML-RPC client view
* @param zibo\xmlrpc\form\ClientForm $form The form of the client
* @param zibo\library\xmlrpc\Request $request
* @param zibo\library\xmlrpc\Response $response
* @param string $responseString
* @param float $time Time spent on the request in seconds
* @return null
*/
public function __construct(ClientForm $form, Request $request = null, Response $response = null, $responseString = null, $time = null)
{
parent::__construct(self::TEMPLATE);
$this->set('form', $form);
$this->set('time', $time);
$this->set('requestString', null);
$this->set('responseString', null);
if ($request) {
$this->set('requestString', String::addLineNumbers(trim($request->getXmlString())));
}
if ($responseString && !$response) {
$this->set('responseString', String::addLineNumbers(trim($responseString)));
} elseif ($response) {
$this->set('responseString', String::addLineNumbers(trim($response->getXmlString())));
$errorCode = $response->getErrorCode();
if ($errorCode) {
$this->set('error', $errorCode . ': ' . $response->getErrorMessage());
} else {
$parser = new ParameterParser();
$result = $parser->unparse($response->getValue(), true);
$this->set('result', $result);
}
}
$this->addStyle(self::STYLE);
}
示例2: addValidator
/**
* Adds a custom validator for a specified field
* @param string $fieldName Name of the field
* @param zibo\library\validation\validator\Validator $validator The validator for the field
* @return null
*/
public function addValidator($fieldName, Validator $validator)
{
if (String::isEmpty($fieldName)) {
throw new ZiboException('Cannot add the validator: provided fieldname is empty');
}
$this->validators[$fieldName][] = $validator;
}
示例3: setName
/**
* Set the name of this field
* @param string $name
* @return null
* @throws zibo\library\database\exception\DatabaseException when the name is empty or not a string
*/
private function setName($name)
{
if (!String::isString($name, String::NOT_EMPTY)) {
throw new DatabaseException('Provided name is empty');
}
$this->name = $name;
}
示例4: setName
/**
* Set the name of the validator
* @param string $name
* @return null
* @throws zibo\ZiboException when $name is not a string
* @throws zibo\library\orm\exception\ModelException when $name is empty
*/
private function setName($name)
{
if (String::isEmpty($name)) {
throw new OrmException('Name is empty');
}
$this->name = $name;
}
示例5: setFieldName
/**
* Sets the field name for objects or arrays passed to this decorator
* @param string $fieldName
* @return null
* @throws zibo\ZiboException when the field name is empty or an object
*/
protected function setFieldName($fieldName)
{
if ($fieldName != null && String::isEmpty($fieldName)) {
throw new ZiboException('Provided field name is empty');
}
$this->fieldName = $fieldName;
}
示例6: setAction
private function setAction($action)
{
if (String::isEmpty($action)) {
$action = Dispatcher::ACTION_ASTERIX;
}
$this->action = $action;
}
示例7: setMethodName
/**
* Sets the method name for the request
* @param string $methodName
* @return null
* @throws zibo\library\xmlrpc\exception\XmlRpcException when the provided method name is empty
*/
protected function setMethodName($methodName)
{
if (String::isEmpty($methodName)) {
throw new XmlRpcException('Method name cannot be empty');
}
$this->methodName = $methodName;
}
示例8: processRequest
/**
* Process the request, get the field value
* @return null
*/
public function processRequest()
{
parent::processRequest();
if ($this->value && !String::looksLikeUrl($this->value)) {
$this->value = 'http://' . $this->value;
}
}
示例9: register
/**
* Register a new thumbnailer into this factory
* @param string name name of the thumbnailer
* @param Thumbnailer thumbnailer Thumbnailer instance
*/
public function register($name, Thumbnailer $thumbnailer)
{
if (String::isEmpty($name)) {
throw new ThumbnailException('Name is empty');
}
$this->thumbnailers[$name] = $thumbnailer;
}
示例10: setExpression
/**
* Sets the expression string
* @param string $expression
* @return null
* @throws zibo\ZiboException when the expression is empty or invalid
*/
private function setExpression($expression)
{
if (String::isEmpty($expression)) {
throw new OrmException('Provided expression is empty');
}
$this->expression = $expression;
}
示例11: parseTag
/**
* Parses the tag
* @param string $content Content of the tag
* @param array $parameters Parameters of the tag
* @return string HTML replacement for the tag
*/
public function parseTag($content, array $parameters)
{
if (!$content || !String::looksLikeUrl($content)) {
return false;
}
$width = null;
$height = null;
$alt = null;
if (array_key_exists(0, $parameters) && strpos($parameters[0], 'x')) {
// [img=<width>x<height>]url[/img]
list($width, $height) = explode($parameters[0]);
} else {
if (array_key_exists('width', $parameters)) {
// [img width=<width>]url[/img]
$width = $parameters['width'];
} elseif (array_key_exists('w', $parameters)) {
// [img w=<width>]url[/img]
$width = $parameters['w'];
}
if (array_key_exists('height', $parameters)) {
// [img height=<height>]url[/img]
$height = $parameters['height'];
} elseif (array_key_exists('h', $parameters)) {
// [img h=<height>]url[/img]
$height = $parameters['h'];
}
}
if (array_key_exists('alt', $parameters)) {
$alt = $parameters['alt'];
}
return $this->getImageHtml($content, $width, $height, $alt);
}
示例12: setHost
/**
* Sets the host of this connection
* @param string $host
* @return null
* @throws zibo\library\network\exception\ConnectionException when the host is invalid
*/
protected function setHost($host)
{
if (String::isEmpty($host)) {
throw new ConnectionException('Could not set the host: invalid host provided');
}
$this->host = $host;
}
示例13: quoteIdentifier
/**
* Quotes a database identifier
* @param string $identifier Identifier to quote
* @return string Quoted identifier
* @throws zibo\library\database\exception\DatabaseException when the provided identifier is empty or not a scalar value
*/
public function quoteIdentifier($identifier)
{
if (!String::isString($identifier, String::NOT_EMPTY)) {
throw new DatabaseException('Provided identifier is empty');
}
return $identifier;
}
示例14: setLabel
/**
* Sets the label for this field
* @param string $label Translation key for the name of this field
* @return null
*/
public function setLabel($label)
{
if ($label !== null && String::isEmpty($label)) {
throw new OrmException('Provided label is empty');
}
$this->label = $label;
}
示例15: setName
/**
* Sets the name of the namespace
* @param string $name
* @return null
* @throws zibo\ZiboException when the provided name is empty or invalid
*/
private function setName($name)
{
if (String::isEmpty($name)) {
throw new ZiboException('Provided name is empty');
}
$this->name = $name;
}