本文整理汇总了PHP中String::create方法的典型用法代码示例。如果您正苦于以下问题:PHP String::create方法的具体用法?PHP String::create怎么用?PHP String::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFromArrayToArrayList
function testFromArrayToArrayList()
{
$input = array("one", "two");
$output = String::fromPrimitives($input);
$this->assertEqual(String::create("one"), $output->get(0));
$this->assertEqual(String::create("two"), $output->get(1));
}
示例2: testOkIndex
function testOkIndex()
{
$bla = String::create("Bla");
$this->assertEqual(String::create("B"), $bla->charAt(0));
$this->assertEqual(String::create("l"), $bla->charAt(1));
$this->assertEqual(String::create("a"), $bla->charAt(2));
}
示例3: __construct
public function __construct($url)
{
$this->url = $url;
$viewParts = String::create($url)->split(self::URL_DELIMITER, 2);
$this->view = $viewParts->get(0)->getPrimitive();
$this->params = $viewParts->size() > 1 ? String::toPrimitives($viewParts->get(1)->split("/")) : array();
}
示例4: getHref
protected function getHref()
{
if (!String::create($this->action)->trim()->startsWith("\$") && $this->isLinkEnabled()) {
return "#" . $this->action;
}
return "#";
}
示例5: create
public static function create($lang)
{
$content = String::create(file_get_contents("bean/games/boggle/data/blocks/{$lang}"));
$layout = new ArrayList("String");
foreach ($content->split("\n") as $die) {
$layout->add($die->split(" ")->getRandomElement());
}
$layout->shuffle();
return new BoggleGrid($layout);
}
示例6: getChildrenWithTag
private function getChildrenWithTag($tagName)
{
$tagNameStr = String::create($tagName);
$result = new ArrayList("XmlElement");
foreach ($this->children as $child) {
if ($child->getName()->equals($tagNameStr)) {
$result->add($child);
}
}
return $result;
}
示例7: __construct
public function __construct($get, $post, $files)
{
$this->get = HashMap::fromArray("string", "?", $get);
$this->post = HashMap::fromArray("string", "?", $post);
$this->files = $files;
$this->postVars = new ArrayList("MovicoPostVar");
foreach ($post as $name => $value) {
if (String::create($name)->startsWith("#")) {
$type = isset($post[self::TYPE_PREFIX . $name]) ? $post[self::TYPE_PREFIX . $name] : self::DEFAULT_TYPE;
$this->postVars->add(new MovicoPostVar($name, $value, $type));
}
}
}
示例8: getXmlElement
private function getXmlElement(SimpleXMLElement $el)
{
$result = new XmlElement(String::create($el->getName()));
$result->setText(String::create($el));
foreach ($el->children() as $child) {
$xmlChild = $this->getXmlElement($child);
$xmlChild->setParent($result);
$result->addChild($xmlChild);
}
foreach ($el->attributes() as $name => $val) {
$result->addAttribute($name, (string) $val);
}
return $result;
}
示例9: getXmlElement
private function getXmlElement(DOMElement $el)
{
$result = new XmlElement(String::create($el->tagName));
for ($i = 0; $i < $el->childNodes->length; $i++) {
$child = $el->childNodes->item($i);
if ($child instanceof DOMText) {
$result->setText(String::create($child->textContent));
} elseif ($child instanceof DOMElement) {
$xmlChild = $this->getXmlElement($child);
$xmlChild->setParent($result);
$result->addChild($xmlChild);
}
}
for ($i = 0; $i < $el->attributes->length; $i++) {
$attr = $el->attributes->item($i);
$result->addAttribute($attr->nodeName, $attr->nodeValue);
}
return $result;
}
示例10: verifyXmlContents
private function verifyXmlContents(XmlFactory $xmlFactory)
{
$xmlString = "<root><element1 attribute1=\"value1\" attribute2=\"value2\"/><element2><child>bla</child></element2></root>";
$file = $xmlFactory->fromString(String::create($xmlString));
$this->assertEqual("root", $file->getRootElement()->getName());
$root = $file->getRootElement();
$this->assertEqual(2, $root->getNbChildren());
$this->assertEqual(1, $root->getNbChildren("element1"));
$children = $root->getChildren();
$el1 = $children->getFirst();
$this->assertEqual("element1", $el1->getName());
$this->assertEqual(2, $el1->getNbAttributes());
$this->assertEqual("value1", $el1->getAttribute("attribute1"));
$this->assertEqual("value2", $el1->getAttribute("attribute2"));
$el2 = $children->getLast();
$this->assertEqual("element2", $el2->getName());
$child = $el2->getChildren()->getFirst();
$this->assertEqual("bla", $child->getText());
$this->assertEqual("element2", $child->getParent()->getName());
$this->assertEqual($xmlString, $root->asXml());
$this->assertEqual(1, $root->getNbDescendants("child"));
}
示例11: match
/**
* Matches a string against this regex
* @param string $input string to matcht he regex against
* @return array|boolean Array of matching results. False if does not match
*/
public function match($input)
{
String::create($input);
return preg_match($this->value, $input->value, $matches) ? $matches : false;
}
示例12: getCurrentColumnClass
protected function getCurrentColumnClass($i)
{
$this->classList = String::create($this->columnClasses)->split(",");
return $this->classList->get($i % $this->classList->size())->getPrimitive();
}
示例13: __construct
public function __construct($expression)
{
$this->expression = String::create($expression);
}
示例14: str
private static function str($description = null, $source = null)
{
return String::create('validation/error:notEmpty', 'Should be not empty', $description, $source);
}
示例15: shouldBeRendered
public function shouldBeRendered($index)
{
$renderedStr = String::create($this->rendered);
if ($renderedStr->contains("!")) {
return !$this->getConvertedValue($renderedStr->replace("!", "")->__toString(), $index);
} else {
return $this->getConvertedValue($this->rendered, $index);
}
}