Best Gherkin-php code snippet using StringUtils.ltrim
EditCmsBuilder.php
Source:EditCmsBuilder.php
...131 if(substr($id,0,1) != '#')132 throw new Exception('The id attribute must be a valid role beginning with #');133 if(!$this->__hasPermission($view_perms) || !$this->__hasNodePermission($node_view_perms))134 return;135 $id = ltrim($id, '#');136 $schemafield = $this->schema->getMetaDef($id);137 $uid = $this->_generateUniqueID($id);138 $fullid = "#{$id}";139 $fulluid = "#{$uid}";140 $this->xhtml[] = " <li class=\"input-full-width field wysiwyg {$this->_fieldClasses($schemafield)}\">";141 $this->xhtml[] = " <label for=\"{$uid}\">{$schemafield->Title}</label>";142 if($this->__hasPermission($edit_perms) && $this->__hasNodePermission($node_edit_perms)) {143 $this->xhtml[] = " <div><div id=\"{$uid}-editor\">";144 $this->xhtml[] = " <textarea id=\"{$uid}\" name=\"{$fulluid}\">%{$fullid}%</textarea>";145 $this->xhtml[] = " </div></div>";146 $t = new Transport();147 $t->String = '';148 $this->Events->trigger('render-wysiwyg-js', $t, $uid,$fulluid, $attributes);149 $this->js[] = $t->String;150 $t = new Transport();151 $t->String = '';152 $this->Events->trigger('render-wysiwyg-js-second-pass', $t, $uid,$fulluid, $attributes);153 $this->js[] = $t->String;154 $t = new Transport();155 $t->String = '';156 $this->Events->trigger('render-wysiwyg-xhtml', $t, $uid,$fulluid, $attributes);157 $this->xhtml[] = $t->String;158 } else159 $this->xhtml[] = " <div><p class=\"read-only\">%{$fulluid}%</p></div>";160 }161 protected function _wysiwyg() {162 $this->__closeLI();163 }164 protected function datewidget() {165 extract($attributes = array_merge(166 array(167 'id' => '',168 'width' => 'quarter',169 'edit_perms' => null,170 'view_perms' => null,171 'node_edit_perms' => null,172 'node_view_perms' => null,173 ),174 $this->_attributes()));175 $this->attributes = $attributes;176 if(empty($id))177 throw new Exception('Missing id attribute on datewidget');178 if(substr($id,0,1) != '#')179 throw new Exception('The id attribute must be a valid role beginning with #');180 if(!$this->__hasPermission($view_perms) || !$this->__hasNodePermission($node_view_perms))181 return;182 $id = ltrim($id, '#');183 $schemafield = $this->schema->getMetaDef($id);184 $vArray = $schemafield->Validation->getValidationArray();185 if(!empty($vArray['dateonly']) && $vArray['dateonly'] == 'true')186 $attributes['dateOnly'] = true;187 $uid = $this->_generateUniqueID($id);188 $fullid = "#{$id}";189 $fulluid = "#{$uid}";190 $this->xhtml[] = " <li class=\"input-{$width}-width field {$this->_fieldClasses($schemafield)}\">";191 $this->xhtml[] = " <label for=\"{$uid}\">{$schemafield->Title}</label>";192 if($this->__hasPermission($edit_perms) && $this->__hasNodePermission($node_edit_perms)) {193 $this->xhtml[] = " <div id=\"{$uid}-holder\">";194 $this->xhtml[] = " <input id=\"{$uid}\" type=\"text\" value=\"{% filter date?value=Data:{$fullid}&format=Y-m-d H:i:s %}\" name=\"{$fulluid}\" class=\"datewidget\"/>";195 $this->xhtml[] = " </div>";196 $this->xhtml[] = " <script type=\"text/javascript\">";197 $this->xhtml[] = " new DateWidget('{$uid}', '{% filter date?value=Data:{$fullid}&format=Y-m-d %}', '{% filter date?value=Data:{$fullid}&format=g:i A %}', ".JSONUtils::encode($attributes).");";198 $this->xhtml[] = " </script>";199 } else200 $this->xhtml[] = " <div><p class=\"read-only\">{% filter date?value=Data:{$fullid}&format=Y-m-d %}</p></div>";201 }202 protected function _datewidget() {203 $this->__closeLI();204 }205 protected function tagwidget() {206 $attributes = array_merge(207 array(208 'id' => '',209 'width' => 'quarter',210 'class' => 'NodeTagWidget',211 'partial' => '',212 'edit_perms' => null,213 'view_perms' => null,214 'node_edit_perms' => null,215 'node_view_perms' => null,216 ),217 $this->_attributes());218 extract($attributes);219 $this->attributes = $attributes;220 if(empty($id))221 throw new Exception('Missing id attribute on tagwidget');222 if(substr($id,0,1) != '#')223 throw new Exception('The id attribute must be a valid role beginning with #');224 if(!$this->__hasPermission($view_perms) || !$this->__hasNodePermission($node_view_perms))225 return;226 $id = ltrim($id, '#');227 $schemafield = $this->schema->getTagDef($id);228 if(empty($partial))229 $partial = $schemafield->Partial->toString();230 $widgetOptions = $this->_buildWidgetOptions($schemafield,$attributes);231 $widgetOptions[] = "ReadOnly: " . ($this->__hasPermission($edit_perms) && $this->__hasNodePermission($node_edit_perms) ? "false" : "true");232 $widgetOptions = "{\n".implode(",\n", $widgetOptions)."\n}";233 $uid = $this->_generateUniqueID($id);234 $taggableRecord = 'taggableRecord';235 if (array_key_exists('uid', $this->attributes))236 $taggableRecord = 'uniqueTaggableRecord'.$this->attributes['uid'];237 $this->js[] = " new {$class}(238 document.{$taggableRecord},239 new TagPartial('{$partial}'),240 '#{$uid}',241 {$widgetOptions}242 );";243 $this->xhtml[] = " <li class=\"input-{$width}-width field {$this->_fieldClasses($schemafield)}\">";244 $this->xhtml[] = " <div id=\"{$uid}\"></div>";245 }246 protected function _tagwidget() {247 $this->__closeLI();248 }249 protected function textarea() {250 extract($attributes = array_merge(251 array(252 'id' => '',253 'rows' => '4',254 'width' => 'quarter',255 'edit_perms' => null,256 'view_perms' => null,257 'node_edit_perms' => null,258 'node_view_perms' => null,259 ),260 $this->_attributes()));261 $this->attributes = $attributes;262 if(empty($id))263 throw new Exception('Missing id attribute on textbox');264 if(substr($id,0,1) != '#')265 throw new Exception('The id attribute must be a valid role beginning with #');266 if(!$this->__hasPermission($view_perms) || !$this->__hasNodePermission($node_view_perms))267 return;268 $id = ltrim($id, '#');269 $schemafield = $this->schema->getMetaDef($id);270 $uid = $this->_generateUniqueID($id);271 $fullid = "#{$id}";272 $fulluid = "#{$uid}";273 $this->xhtml[] = " <li class=\"input-{$width}-width field {$this->_fieldClasses($schemafield)}\">";274 $this->xhtml[] = " <label for=\"{$uid}\">{$schemafield->Title}</label>";275 $this->xhtml[] = " <div>";276 if($this->__hasPermission($edit_perms) && $this->__hasNodePermission($node_edit_perms))277 $this->xhtml[] = " <textarea id=\"{$uid}\" rows=\"{$rows}\" name=\"{$fulluid}\">%{$fullid}%</textarea>";278 else279 $this->xhtml[] = " <p class=\"read-only\">%{$fullid}%</p>";280 $this->xhtml[] = " </div>";281 }282 protected function _textarea() {283 $this->__closeLI();284 }285 protected function textbox() {286 $attributes = array_merge(287 array(288 'id' => '',289 'width' => 'quarter',290 'maxlength' => '255',291 'amazonsearch' => false,292 'wordcount' => false,293 'charcount' => false,294 'newwindow' => false,295 'edit_perms' => null,296 'view_perms' => null,297 'node_edit_perms' => null,298 'node_view_perms' => null,299 ),300 $this->_attributes());301 extract($attributes);302 $this->attributes = $attributes;303 if(empty($id))304 throw new Exception('Missing id attribute on textbox');305 if(substr($id,0,1) != '#')306 throw new Exception('The id attribute must be a valid role beginning with #');307 if(!$this->__hasPermission($view_perms) || !$this->__hasNodePermission($node_view_perms))308 return;309 $id = ltrim($id, '#');310 $schemafield = $this->schema->getMetaDef($id);311 $validation = $schemafield->getValidation()->getValidationArray();312 if (in_array($validation['datatype'], explode('|', 'string|slug|slugwithslash|url|html|email')) && in_array('max', $validation))313 $maxlength = $validation['max'];314 $uid = $this->_generateUniqueID($id);315 $fullid = "#{$id}";316 $fulluid = "#{$uid}";317 $this->xhtml[] = " <li class=\"input-{$width}-width field {$this->_fieldClasses($schemafield)}\">";318 $this->xhtml[] = " <label for=\"{$uid}\">{$schemafield->Title}</label>";319 $this->xhtml[] = " <div>";320 if($this->__hasPermission($edit_perms) && $this->__hasNodePermission($node_edit_perms))321 $this->xhtml[] = " <input id=\"{$uid}\" type=\"text\" maxlength=\"{$maxlength}\" name=\"{$fulluid}\" value=\"%{$fullid}%\"/>";322 else323 $this->xhtml[] = " <p class=\"read-only\">%{$fullid}%</p>";324 $this->xhtml[] = " </div>";325 if($amazonsearch && json_decode($amazonsearch) == true) {326 $this->js[] = "$('#{$uid}').addAmazonSearch();";327 }328 if($newwindow && json_decode($newwindow) == true) {329 $this->js[] = "$('#{$uid}').addNewWindow();";330 }331 if($wordcount && json_decode($wordcount) == true) {332 $this->js[] = "$('#{$uid}').addWordCount();";333 }334 if($charcount && json_decode($charcount) == true) {335 $this->js[] = "$('#{$uid}').addCharCount();";336 }337 }338 protected function _textbox() {339 $this->__closeLI();340 }341 protected function __hasPermission($perms) {342 if(!empty($perms)) {343 $perms = explode(',',$perms);344 foreach($perms as $perm) {345 if(!$this->Permissions->checkPermission($perm)) {346 return false;347 }348 }349 }350 return true;351 }352 protected function __hasNodePermission($perms) {353 if(!empty($perms)) {354 $perms = explode(',',$perms);355 foreach($perms as $perm) {356 if(!$this->NodePermissions->check($perm, $this->getParameter('NodeRef'))) {357 return false;358 }359 }360 }361 return true;362 }363 protected function __closeLI() {364 $attributes = array_merge( array( 'view_perms' => null, 'node_view_perms' => null ), $this->_attributes());365 extract($attributes);366 if(!$this->__hasPermission($view_perms) || !$this->__hasNodePermission($node_view_perms))367 return;368 $this->xhtml[] = " </li>";369 }370 protected function checkbox() {371 extract($attributes = array_merge(372 array(373 'id' => '',374 'width' => 'quarter',375 'edit_perms' => null,376 'view_perms' => null,377 'node_edit_perms' => null,378 'node_view_perms' => null,379 ),380 $this->_attributes()));381 $this->attributes = $attributes;382 if(empty($id))383 throw new Exception('Missing id attribute on textbox');384 if(substr($id,0,1) != '#')385 throw new Exception('The id attribute must be a valid role beginning with #');386 if(!$this->__hasPermission($view_perms) || !$this->__hasNodePermission($node_view_perms))387 return;388 $id = ltrim($id, '#');389 $schemafield = $this->schema->getMetaDef($id);390 $uid = $this->_generateUniqueID($id);391 $fullid = "#{$id}";392 $fulluid = "#{$uid}";393 $this->xhtml[] = " <li class=\"input-{$width}-width checkbox field {$this->_fieldClasses($schemafield)}\">";394 $this->xhtml[] = " <label>{$schemafield->Title}?</label>";395 $this->xhtml[] = " <div>";396 if($this->__hasPermission($edit_perms) && $this->__hasNodePermission($node_edit_perms)) {397 $this->xhtml[] = " <input id=\"{$uid}\" type=\"checkbox\" name=\"{$fulluid}\" {% if Data:{$fullid} %}checked=\"checked\"{% endif %} value=\"1\" /> <label for=\"{$uid}\">Yes</label>";398 $this->xhtml[] = " <input type=\"hidden\" name=\"_{$fulluid}\" value=\"0\" />";399 } else400 $this->xhtml[] = " <p class=\"read-only\">{% if Data:{$fullid} %}Yes{% else %}No{% endif %}</p>";401 $this->xhtml[] = " </div>";402 }403 protected function _checkbox() {404 $this->__closeLI();405 }406 protected function display() {407 extract($attributes = array_merge(408 array(409 'id' => '',410 'width' => 'quarter',411 'view_perms' => null,412 'node_view_perms' => null,413 'preformatted' => null,414 ),415 $this->_attributes()));416 $this->attributes = $attributes;417 if(empty($id))418 throw new Exception('Missing id attribute on display');419 if(substr($id,0,1) != '#')420 throw new Exception('The id attribute must be a valid role beginning with #');421 if(!$this->__hasPermission($view_perms) || !$this->__hasNodePermission($node_view_perms))422 return;423 $id = ltrim($id, '#');424 $isTag = false;425 if($this->schema->hasMetaDef($id)) {426 $schemafield = $this->schema->getMetaDef($id);427 } else {428 $schemafield = $this->schema->getTagDef($id);429 $isTag = true;430 }431 $validationArray = $schemafield->Validation->getValidationArray();432 $fullid = "#{$id}";433 $this->xhtml[] = " <li class=\"input-{$width}-width field {$this->_fieldClasses($schemafield)} display\">";434 $this->xhtml[] = " <label for=\"{$id}\">{$schemafield->Title}</label>";435 $this->xhtml[] = " <div>";436 if($validationArray['datatype'] == 'url') {437 $this->xhtml[] = " <a href=\"%{$fullid}%\" target=\"new\">%{$fullid}%</a>";438 } elseif($validationArray['datatype'] == 'date') {439 $this->xhtml[] = " {% filter date?value=Data:{$fullid}&format=M j, Y g:i A T&nonbreaking=true %}";440 } elseif($validationArray['datatype'] == 'boolean') {441 $this->xhtml[] = " {% if Data:{$fullid} %}YES{% else %}NO{% endif %}";442 } else {443 // If this is a tag, it will be an array, so we use implode to convert it to a string.444 if ($isTag) {445 $this->xhtml[] = " {% filter display-implode?value=Data:{$fullid}&glue=<br> %}";446 } else {447 if ($attributes['preformatted']) {448 $this->xhtml[] = " <pre>%{$fullid}%</pre>";449 } else {450 $this->xhtml[] = " %{$fullid}%";451 }452 }453 }454 $this->xhtml[] = " </div>";455 }456 protected function _display() {457 $this->__closeLI();458 }459 protected function image() {460 extract($attributes = array_merge(461 array(462 'id' => '',463 'width' => 'quarter',464 'view_perms' => null,465 'node_view_perms' => null466 ),467 $this->_attributes()));468 $this->attributes = $attributes;469 if(empty($id))470 throw new Exception('Missing id attribute on image');471 if(!$this->__hasPermission($view_perms) || !$this->__hasNodePermission($node_view_perms))472 return;473 $fullid = $id;474 $this->xhtml[] = " <li class=\"input-{$width}-width field \">";475 $this->xhtml[] = " <div>";476 $this->xhtml[] = " <a href=\"%{$fullid}%\" title=\"Open image in new window\" target=\"_blank\"><image border=\"0\" src=\"%{$fullid}%\"/></a>";477 $this->xhtml[] = " </div>";478 }479 protected function _image() {480 $this->__closeLI();481 }482 protected function link() {483 extract($attributes = array_merge(484 array(485 'id' => '',486 'width' => 'quarter',487 'view_perms' => null,488 'node_view_perms' => null489 ),490 $this->_attributes()));491 $this->attributes = $attributes;492 if(empty($id))493 throw new Exception('Missing id attribute on image');494 if(!$this->__hasPermission($view_perms) || !$this->__hasNodePermission($node_view_perms))495 return;496 $fullid = $id;497 $this->xhtml[] = " <li class=\"input-{$width}-width field \">";498 $this->xhtml[] = " <div>";499 $this->xhtml[] = " <a href=\"%{$fullid}%\" title=\"Open in new window\" target=\"_blank\">%{$fullid}%</a>";500 $this->xhtml[] = " </div>";501 }502 protected function _link() {503 $this->__closeLI();504 }505 protected function dropdown() {506 $attributes = array_merge(507 array(508 'id' => '',509 'width' => 'quarter',510 'edit_perms' => null,511 'view_perms' => null,512 'node_edit_perms' => null,513 'node_view_perms' => null,514 ),515 $this->_attributes());516 extract($attributes);517 if(empty($id))518 throw new Exception('Missing id attribute on dropdown');519 if(substr($id,0,1) != '#')520 throw new Exception('The id attribute must be a valid role beginning with #');521 if(!$this->__hasPermission($view_perms) || !$this->__hasNodePermission($node_view_perms))522 return;523 $id = ltrim($id, '#');524 $schemafield = $this->schema->getMetaDef($id);525 if(!$this->xml->isEmptyElement){526 require_once PATH_SYSTEM .'/vendors/Xml2Assoc.php';527 $children = (array)Xml2Assoc::parseXml($this->xml, true);528 }else529 $children = array();530 $uid = $this->_generateUniqueID($id);531 $fullid = "#{$id}";532 $fulluid = "#{$uid}";533 $this->xhtml[] = " <li class=\"input-{$width}-width field {$this->_fieldClasses($schemafield)}\">";534 $this->xhtml[] = " <label for=\"{$uid}\">{$schemafield->Title}</label>";535 $this->xhtml[] = " <div>";536 if($this->__hasPermission($edit_perms) && $this->__hasNodePermission($node_edit_perms)) {537 $this->xhtml[] = " <select name=\"{$fulluid}\" id=\"{$uid}\">";...
Properties.php
Source:Properties.php
...26use function explode;27use function is_array;28use function is_string;29use function iterator_to_array;30use function ltrim;31use function mb_strtolower;32use function rand;33use function rtrim;34use function strlen;35use function substr;36use function trim;37class Properties{38 /** @var bool */39 private $caseInsensitive;40 /** @var string */41 private $separator;42 /** @var string|null */43 private $comment;44 /** @var string|null */45 private $escape;46 private $randomPrefix = 0;47 private $randomKey = 0;48 private $map = [];49 private $order = [];50 private $caseMap = [];51 public static function builder(){52 return new PropertiesBuilder();53 }54 public function __construct(iterable $input, bool $caseInsensitive = false, string $separator = "=", ?string $comment = "#", ?string $escape = "\\"){55 $this->caseInsensitive = $caseInsensitive;56 $this->separator = $separator;57 $this->comment = $comment;58 $this->escape = $escape;59 $this->randomPrefix = $comment . rand() . $comment . rand() . "\$";60 foreach($input as $line){61 $trimmed = trim($line);62 if($trimmed === "" || StringUtils::startsWith($trimmed, $comment)){63 $key = $this->makeRandomKey();64 $this->order[] = $key;65 $this->map[$key] = $line;66 continue;67 }68 if($escape === null){69 $parts = explode($separator, $trimmed);70 $left = rtrim($parts[0]);71 $right = isset($parts[1]) ? ltrim($parts[1]) : true;72 }else{73 [$left, $right] = self::separateLine($trimmed, $separator, $escape);74 }75 $left = $this->convertCase($left);76 if(!isset($this->map[$left])){77 $this->map[$left] = [];78 }79 $this->order[] = [$left, count($this->map[$left])];80 $this->map[$left][] = $right;81 }82 }83 private static function separateLine(string $trimmed, string $separator, string $escape){84 assert(strlen($escape) === 1);85 $output = "";86 for($i = 0; $i < strlen($trimmed); $i++){87 $output .= $trimmed{$i};88 if($trimmed{$i} === $escape){89 $i++;90 }91 if(StringUtils::substringAt($trimmed, $separator, $i)){92 return [rtrim(substr($output, 0, -1)), ltrim(substr($trimmed, $i + strlen($separator)))];93 }94 }95 return [$trimmed, true];96 }97 private function makeRandomKey() : string{98 return $this->randomPrefix . ($this->randomKey++);99 }100 private function convertCase(string $string) : string{101 if(!$this->caseInsensitive){102 return $string;103 }104 $lower = mb_strtolower($string);105 if(isset($this->caseMap[$lower])){106 return $this->caseMap[$lower];...
TaskPublisher.php
Source:TaskPublisher.php
...70 try {71 RedisCmd::rPush($cacheKey, JsonUtils::toJson($payload));72 $msg = sprintf(73 'success to publish normal task: %s, params: %s',74 ltrim(str_replace('/', "\\", $taskClass), "\\"),75 empty($taskParams) ? '{}' : JsonUtils::toJson($taskParams)76 );77 if ($enableLogging) {78 $logger->info($msg);79 }80 } catch (Throwable $ex) {81 $logger->error(ExceptionUtils::getStackTrace($ex));82 }83 }84 public static function publishDelayable(85 string $taskClass,86 array $taskParams,87 int $runAt,88 ?RetryPolicy $retryPolicy = null89 ): void90 {91 $taskClass = str_replace("\\", '/', $taskClass);92 $taskClass = StringUtils::ensureLeft($taskClass, '/');93 if (empty($taskParams)) {94 $taskParams = [];95 }96 $payload = compact('taskClass', 'taskParams');97 $payload['runAt'] = Carbon::createFromTimestamp($runAt, new DateTimeZone('Asia/Shanghai'))->format(DateTimeFormat::FULL);98 if ($retryPolicy !== null) {99 $payload = array_merge($payload, $retryPolicy->toArray());100 }101 $cacheKey = self::delayableQueueCacheKey();102 $logger = Log::channel('task');103 $enableLogging = AppConf::getBoolean('logging.enable-task-log');104 try {105 RedisCmd::zAdd($cacheKey, $runAt, JsonUtils::toJson($payload));106 $msg = sprintf(107 'success to publish delayable task: %s, run at: %s, params: %s',108 ltrim(str_replace('/', "\\", $taskClass), "\\"),109 $payload['runAt'],110 empty($taskParams) ? '{}' : JsonUtils::toJson($taskParams)111 );112 if ($enableLogging) {113 $logger->info($msg);114 }115 } catch (Throwable $ex) {116 $logger->error(ExceptionUtils::getStackTrace($ex));117 }118 }119 public static function publishDelayableWithDelayAmount(120 string $taskClass,121 array $taskParams,122 int $delayAmount,...
PhpAnnoAnalyzer.php
Source:PhpAnnoAnalyzer.php
...130 return $constructorParams;131 }132 133 private function isNewClass($string) {134 return StringUtils::startsWith(Phpbob::KEYWORD_NEW, ltrim($string));135 }136 137 private function isVariable($string) {138 return StringUtils::startsWith(Phpbob::VARIABLE_PREFIX, ltrim($string));139 }
...
PhpbobAnalyzingUtils.php
Source:PhpbobAnalyzingUtils.php
...13 if (!($phpStatement instanceof StatementGroup)) return false;14 15 return preg_match('/^(' . preg_quote(Phpbob::KEYWORD_FINAL) . '\s+)?('16 . preg_quote(Phpbob::KEYWORD_ABSTRACT) . '\s+)?'17 . preg_quote(Phpbob::KEYWORD_CLASS). '/i', ltrim($phpStatement->getCode()));18 }19 20 public static function isTypeStatement(PhpStatement $phpStatement) {21 return self::isClassStatement($phpStatement) || self::isInterfaceStatement($phpStatement)22 || self::isTraitStatement($phpStatement);23 }24 25 public static function isInterfaceStatement(PhpStatement $phpStatement) {26 if (!($phpStatement instanceof StatementGroup)) return false;27 28 return StringUtils::startsWith(Phpbob::KEYWORD_INTERFACE,29 ltrim(strtolower($phpStatement->getCode())));30 }31 32 public static function isTraitStatement(PhpStatement $phpStatement) {33 if (!($phpStatement instanceof StatementGroup)) return false;34 35 return StringUtils::startsWith(Phpbob::KEYWORD_TRAIT,36 ltrim(strtolower($phpStatement->getCode())));37 }38 39 public static function isPropertyStatement(PhpStatement $phpStatement) {40 return $phpStatement instanceof SingleStatement41 && preg_match('/(' . preg_quote(Phpbob::CLASSIFIER_PRIVATE) .42 '|' . preg_quote(Phpbob::CLASSIFIER_PROTECTED) .43 '|' . preg_quote(Phpbob::CLASSIFIER_PUBLIC) . ')\s+('44 . preg_quote(Phpbob::KEYWORD_STATIC) . '\s+)?' .45 preg_quote(Phpbob::VARIABLE_PREFIX) . '/i', $phpStatement->getCode());46 }47 48 public static function isConstStatement(PhpStatement $phpStatement) {49 return $phpStatement instanceof SingleStatement50 && StringUtils::startsWith(Phpbob::KEYWORD_CONST, ltrim(strtolower($phpStatement->getCode())));51 }52 53 public static function isAnnotationStatement(PhpStatement $phpStatement) {54 return self::isMethodStatement($phpStatement)55 && preg_match('/private\s+static\s+function\s+_annos.*\(.*\)/i',56 $phpStatement->getCode());57 }58 59 public static function isMethodStatement(PhpStatement $phpStatement) {60 return !!preg_match('/' . preg_quote(Phpbob::KEYWORD_FUNCTION)61 . '.*\(.*\)/i', $phpStatement->getCode());62 }63 64 public static function isNamespaceStatement(PhpStatement $phpStatement) {65 return $phpStatement instanceof SingleStatement66 && preg_match('/^\s*' . preg_quote(Phpbob::KEYWORD_NAMESPACE) . '\s+/i', $phpStatement->getCode());67 }68 69 public static function isUseStatement(PhpStatement $phpStatement) {70 return $phpStatement instanceof SingleStatement71 && StringUtils::startsWith(Phpbob::KEYWORD_USE, ltrim(strtolower($phpStatement->getCode())));72 }73 74 public static function isTraitUseStatement(PhpStatement $phpStatement) {75 return StringUtils::startsWith(Phpbob::KEYWORD_USE, ltrim(strtolower($phpStatement->getCode())));76 }77 78 public static function purifyPropertyName($propertyName) {79 return str_replace(array(Phpbob::VARIABLE_PREFIX, Phpbob::VARIABLE_REFERENCE_PREFIX), '', $propertyName);80 }
...
Color.class.php
Source:Color.class.php
...27 * @access public28 * @param string $color HTMLå½¢å¼ã®è²ã³ã¼ã29 */30 public function setColor ($color) {31 $color = ltrim($color, '#');32 if (StringUtils::isBlank($color) || Numeric::isZero($color)) {33 $this['red'] = 0;34 $this['green'] = 0;35 $this['blue'] = 0;36 } else if (mb_ereg('^[[:xdigit:]]{6}$', $color)) {37 $this['red'] = hexdec($color[0] . $color[1]);38 $this['green'] = hexdec($color[2] . $color[3]);39 $this['blue'] = hexdec($color[4] . $color[5]);40 } else if (mb_ereg('^[[:xdigit:]]{3}$', $color)) {41 $this['red'] = hexdec($color[0] . $color[0]);42 $this['green'] = hexdec($color[1] . $color[1]);43 $this['blue'] = hexdec($color[2] . $color[2]);44 } else {45 $color = StringUtils::toLower($color);...
MIMEType.class.php
Source:MIMEType.class.php
...11 foreach (ConfigManager::getInstance()->compile('mime') as $entry) {12 $entry = Tuple::create($entry);13 if ($entry['suffixes']) {14 foreach ($entry['suffixes'] as $suffix) {15 $this['.' . ltrim($suffix, '.')] = $entry['type'];16 if ($this->suffixes->hasParameter($entry['type'])) {17 $this->suffixes[] = '.' . ltrim($suffix, '.');18 } else {19 $this->suffixes[$entry['type']] = '.' . ltrim($suffix, '.');20 }21 }22 }23 if ($entry['alias_to']) {24 $this->aliases[$entry['type']] = $entry['alias_to'];25 }26 }27 }28 public function getParameter (?string $name) {29 return parent::getParameter('.' . ltrim(StringUtils::toLower($name), '.'));30 }31 public function setParameter (?string $name, $value) {32 if (!StringUtils::isBlank($value)) {33 $name = '.' . ltrim($name, '.');34 $name = StringUtils::toLower($name);35 parent::setParameter($name, $value);36 }37 }38 public function resolveType ($type) {39 if (StringUtils::isBlank($type)) {40 return MIMEType::DEFAULT_TYPE;41 }42 if ($alias = $this->aliases[$type]) {43 return $alias;44 }45 return $type;46 }47 public function getSuffixes () {...
FileUtils.class.php
Source:FileUtils.class.php
...34 static public function createTemporaryFile ($suffix = null, $class = 'Carrot3\\File') {35 if (StringUtils::isBlank($suffix)) {36 $name = Utils::getUniqueID();37 } else {38 $name = Utils::getUniqueID() . '.' . ltrim($suffix, '.');39 }40 if (!$file = FileUtils::getDirectory('tmp')->createEntry($name, $class)) {41 throw new FileException('ä¸æãã¡ã¤ã«ãçæã§ãã¾ããã');42 }43 return $file;44 }45 static public function createTemporaryDirectory ($class = 'Carrot3\\Directory') {46 $name = Utils::getUniqueID();47 if (!$dir = FileUtils::getDirectory('tmp')->createDirectory($name, $class)) {48 throw new FileException('ä¸æãã£ã¬ã¯ããªãçæã§ãã¾ããã');49 }50 return $dir;51 }52}...
ltrim
Using AI Code Generation
1require_once 'StringUtils.php';2$string = " Hello World ";3echo StringUtils::ltrim($string);4require_once 'StringUtils.php';5$string = " Hello World ";6echo StringUtils::rtrim($string);7require_once 'StringUtils.php';8$string = " Hello World ";9echo StringUtils::trim($string);10require_once 'StringUtils.php';11$string = "Hello World";12echo StringUtils::strpos($string, "W");13require_once 'StringUtils.php';14$string = "Hello World";15echo StringUtils::strrev($string);16require_once 'StringUtils.php';17$string = "Hello World";18echo StringUtils::str_replace("World", "PHP", $string);19require_once 'StringUtils.php';20$string = "Hello World";21echo StringUtils::str_word_count($string);22require_once 'StringUtils.php';23$string = "Hello World";24echo StringUtils::substr_count($string, "o");25require_once 'StringUtils.php';26$string = "Hello World";27echo StringUtils::substr($string, 0, 5);28require_once 'StringUtils.php';29$string = "Hello World";30print_r(StringUtils::str_split($string));
ltrim
Using AI Code Generation
1require_once 'StringUtils.php';2$test = new StringUtils();3$test->ltrim(' hello world! ');4echo $test->result;5echo '<br>';6$test = new StringUtils();7$test->rtrim(' hello world! ');8echo $test->result;9echo '<br>';10$test = new StringUtils();11$test->trim(' hello world! ');12echo $test->result;13echo '<br>';14$test = new StringUtils();15$test->rpad('hello', 10, ' world');16echo $test->result;17echo '<br>';18$test = new StringUtils();19$test->lpad('hello', 10, ' world');20echo $test->result;21echo '<br>';22$test = new StringUtils();23$test->pad('hello', 10, ' world');24echo $test->result;25echo '<br>';26$test = new StringUtils();27$test->chomp('hello world');28echo $test->result;29echo '<br>';30$test = new StringUtils();31$test->chop('hello world');32echo $test->result;33echo '<br>';34$test = new StringUtils();35$test->swapcase('Hello World');36echo $test->result;37echo '<br>';38$test = new StringUtils();39$test->capitalize('hello world');40echo $test->result;41echo '<br>';42$test = new StringUtils();43$test->upcase('hello world');44echo $test->result;45echo '<br>';46$test = new StringUtils();47$test->downcase('hello world');48echo $test->result;49echo '<br>';50$test = new StringUtils();51$test->reverse('hello world');52echo $test->result;53echo '<br>';54$test = new StringUtils();55$test->length('
ltrim
Using AI Code Generation
1require_once 'StringUtils.php';2$str = " this is an example of string ";3echo StringUtils::ltrim($str);4require_once 'StringUtils.php';5$str = " this is an example of string ";6echo StringUtils::rtrim($str);7require_once 'StringUtils.php';8$str = " this is an example of string ";9echo StringUtils::trim($str);10require_once 'StringUtils.php';11$str = " this is an example of string ";12echo StringUtils::ltrimChar($str, 't');13require_once 'StringUtils.php';14$str = " this is an example of string ";15echo StringUtils::rtrimChar($str, 'g');16require_once 'StringUtils.php';17$str = " this is an example of string ";18echo StringUtils::trimChar($str, 't');19require_once 'StringUtils.php';20$str = " this is an example of string ";21echo StringUtils::ltrimChars($str, 't');22require_once 'StringUtils.php';23$str = " this is an example of string ";24echo StringUtils::rtrimChars($str, 'g');25require_once 'StringUtils.php';26$str = " this is an example of string ";27echo StringUtils::trimChars($
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with ltrim on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!