How to use fold class

Best Atoum code snippet using fold

Dn.php

Source:Dn.php Github

copy

Full Screen

...31 const ATTR_CASEFOLD_NONE = 'none';32 const ATTR_CASEFOLD_UPPER = 'upper';33 const ATTR_CASEFOLD_LOWER = 'lower';34 /**35 * The default case fold to use36 *37 * @var string38 */39 protected static $_defaultCaseFold = self::ATTR_CASEFOLD_NONE;40 /**41 * The case fold used for this instance42 *43 * @var string44 */45 protected $_caseFold;46 /**47 * The DN data48 *49 * @var array50 */51 protected $_dn;52 /**53 * Creates a DN from an array or a string54 *55 * @param string|array $dn56 * @param string|null $caseFold57 * @return Zend_Ldap_Dn58 * @throws Zend_Ldap_Exception59 */60 public static function factory($dn, $caseFold = null)61 {62 if (is_array($dn)) {63 return self::fromArray($dn, $caseFold);64 } else if (is_string($dn)) {65 return self::fromString($dn, $caseFold);66 } else {67 /**68 * Zend_Ldap_Exception69 */70 require_once 'Zend/Ldap/Exception.php';71 throw new Zend_Ldap_Exception(null, 'Invalid argument type for $dn');72 }73 }74 /**75 * Creates a DN from a string76 *77 * @param string $dn78 * @param string|null $caseFold79 * @return Zend_Ldap_Dn80 * @throws Zend_Ldap_Exception81 */82 public static function fromString($dn, $caseFold = null)83 {84 $dn = trim($dn);85 if (empty($dn)) {86 $dnArray = array();87 } else {88 $dnArray = self::explodeDn((string)$dn);89 }90 return new self($dnArray, $caseFold);91 }92 /**93 * Creates a DN from an array94 *95 * @param array $dn96 * @param string|null $caseFold97 * @return Zend_Ldap_Dn98 * @throws Zend_Ldap_Exception99 */100 public static function fromArray(array $dn, $caseFold = null)101 {102 return new self($dn, $caseFold);103 }104 /**105 * Constructor106 *107 * @param array $dn108 * @param string|null $caseFold109 */110 protected function __construct(array $dn, $caseFold)111 {112 $this->_dn = $dn;113 $this->setCaseFold($caseFold);114 }115 /**116 * Gets the RDN of the current DN117 *118 * @param string $caseFold119 * @return array120 * @throws Zend_Ldap_Exception if DN has no RDN (empty array)121 */122 public function getRdn($caseFold = null)123 {124 $caseFold = self::_sanitizeCaseFold($caseFold, $this->_caseFold);125 return self::_caseFoldRdn($this->get(0, 1, $caseFold), null);126 }127 /**128 * Gets the RDN of the current DN as a string129 *130 * @param string $caseFold131 * @return string132 * @throws Zend_Ldap_Exception if DN has no RDN (empty array)133 */134 public function getRdnString($caseFold = null)135 {136 $caseFold = self::_sanitizeCaseFold($caseFold, $this->_caseFold);137 return self::implodeRdn($this->getRdn(), $caseFold);138 }139 /**140 * Get the parent DN $levelUp levels up the tree141 *142 * @param int $levelUp143 * @return Zend_Ldap_Dn144 */145 public function getParentDn($levelUp = 1)146 {147 $levelUp = (int)$levelUp;148 if ($levelUp < 1 || $levelUp >= count($this->_dn)) {149 /**150 * Zend_Ldap_Exception151 */152 require_once 'Zend/Ldap/Exception.php';153 throw new Zend_Ldap_Exception(null, 'Cannot retrieve parent DN with given $levelUp');154 }155 $newDn = array_slice($this->_dn, $levelUp);156 return new self($newDn, $this->_caseFold);157 }158 /**159 * Get a DN part160 *161 * @param int $index162 * @param int $length163 * @param string $caseFold164 * @return array165 * @throws Zend_Ldap_Exception if index is illegal166 */167 public function get($index, $length = 1, $caseFold = null)168 {169 $caseFold = self::_sanitizeCaseFold($caseFold, $this->_caseFold);170 $this->_assertIndex($index);171 $length = (int)$length;172 if ($length <= 0) {173 $length = 1;174 }175 if ($length === 1) {176 return self::_caseFoldRdn($this->_dn[$index], $caseFold);177 }178 else {179 return self::_caseFoldDn(array_slice($this->_dn, $index, $length, false), $caseFold);180 }181 }182 /**183 * Set a DN part184 *185 * @param int $index186 * @param array $value187 * @return Zend_Ldap_Dn Provides a fluent interface188 * @throws Zend_Ldap_Exception if index is illegal189 */190 public function set($index, array $value)191 {192 $this->_assertIndex($index);193 self::_assertRdn($value);194 $this->_dn[$index] = $value;195 return $this;196 }197 /**198 * Remove a DN part199 *200 * @param int $index201 * @param int $length202 * @return Zend_Ldap_Dn Provides a fluent interface203 * @throws Zend_Ldap_Exception if index is illegal204 */205 public function remove($index, $length = 1)206 {207 $this->_assertIndex($index);208 $length = (int)$length;209 if ($length <= 0) {210 $length = 1;211 }212 array_splice($this->_dn, $index, $length, null);213 return $this;214 }215 /**216 * Append a DN part217 *218 * @param array $value219 * @return Zend_Ldap_Dn Provides a fluent interface220 */221 public function append(array $value)222 {223 self::_assertRdn($value);224 $this->_dn[] = $value;225 return $this;226 }227 /**228 * Prepend a DN part229 *230 * @param array $value231 * @return Zend_Ldap_Dn Provides a fluent interface232 */233 public function prepend(array $value)234 {235 self::_assertRdn($value);236 array_unshift($this->_dn, $value);237 return $this;238 }239 /**240 * Insert a DN part241 *242 * @param int $index243 * @param array $value244 * @return Zend_Ldap_Dn Provides a fluent interface245 * @throws Zend_Ldap_Exception if index is illegal246 */247 public function insert($index, array $value)248 {249 $this->_assertIndex($index);250 self::_assertRdn($value);251 $first = array_slice($this->_dn, 0, $index + 1);252 $second = array_slice($this->_dn, $index + 1);253 $this->_dn = array_merge($first, array($value), $second);254 return $this;255 }256 /**257 * Assert index is correct and usable258 *259 * @param mixed $index260 * @return boolean261 * @throws Zend_Ldap_Exception262 */263 protected function _assertIndex($index)264 {265 if (!is_int($index)) {266 /**267 * Zend_Ldap_Exception268 */269 require_once 'Zend/Ldap/Exception.php';270 throw new Zend_Ldap_Exception(null, 'Parameter $index must be an integer');271 }272 if ($index < 0 || $index >= count($this->_dn)) {273 /**274 * Zend_Ldap_Exception275 */276 require_once 'Zend/Ldap/Exception.php';277 throw new Zend_Ldap_Exception(null, 'Parameter $index out of bounds');278 }279 return true;280 }281 /**282 * Assert if value is in a correct RDN format283 *284 * @param array $value285 * @return boolean286 * @throws Zend_Ldap_Exception287 */288 protected static function _assertRdn(array $value)289 {290 if (count($value)<1) {291 /**292 * Zend_Ldap_Exception293 */294 require_once 'Zend/Ldap/Exception.php';295 throw new Zend_Ldap_Exception(null, 'RDN Array is malformed: it must have at least one item');296 }297 foreach (array_keys($value) as $key) {298 if (!is_string($key)) {299 /**300 * Zend_Ldap_Exception301 */302 require_once 'Zend/Ldap/Exception.php';303 throw new Zend_Ldap_Exception(null, 'RDN Array is malformed: it must use string keys');304 }305 }306 }307 /**308 * Sets the case fold309 *310 * @param string|null $caseFold311 */312 public function setCaseFold($caseFold)313 {314 $this->_caseFold = self::_sanitizeCaseFold($caseFold, self::$_defaultCaseFold);315 }316 /**317 * Return DN as a string318 *319 * @param string $caseFold320 * @return string321 * @throws Zend_Ldap_Exception322 */323 public function toString($caseFold = null)324 {325 $caseFold = self::_sanitizeCaseFold($caseFold, $this->_caseFold);326 return self::implodeDn($this->_dn, $caseFold);327 }328 /**329 * Return DN as an array330 *331 * @param string $caseFold332 * @return array333 */334 public function toArray($caseFold = null)335 {336 $caseFold = self::_sanitizeCaseFold($caseFold, $this->_caseFold);337 if ($caseFold === self::ATTR_CASEFOLD_NONE) {338 return $this->_dn;339 } else {340 return self::_caseFoldDn($this->_dn, $caseFold);341 }342 }343 /**344 * Do a case folding on a RDN345 *346 * @param array $part347 * @param string $caseFold348 * @return array349 */350 protected static function _caseFoldRdn(array $part, $caseFold)351 {352 switch ($caseFold) {353 case self::ATTR_CASEFOLD_UPPER:354 return array_change_key_case($part, CASE_UPPER);355 case self::ATTR_CASEFOLD_LOWER:356 return array_change_key_case($part, CASE_LOWER);357 case self::ATTR_CASEFOLD_NONE:358 default:359 return $part;360 }361 }362 /**363 * Do a case folding on a DN ort part of it364 *365 * @param array $dn366 * @param string $caseFold367 * @return array368 */369 protected static function _caseFoldDn(array $dn, $caseFold)370 {371 $return = array();372 foreach ($dn as $part) {373 $return[] = self::_caseFoldRdn($part, $caseFold);374 }375 return $return;376 }377 /**378 * Cast to string representation {@see toString()}379 *380 * @return string381 */382 public function __toString()383 {384 return $this->toString();385 }386 /**387 * Required by the ArrayAccess implementation388 *389 * @param int $offset390 * @return boolean391 */392 public function offsetExists($offset)393 {394 $offset = (int)$offset;395 if ($offset < 0 || $offset >= count($this->_dn)) {396 return false;397 } else {398 return true;399 }400 }401 /**402 * Proxy to {@see get()}403 * Required by the ArrayAccess implementation404 *405 * @param int $offset406 * @return array407 */408 public function offsetGet($offset)409 {410 return $this->get($offset, 1, null);411 }412 /**413 * Proxy to {@see set()}414 * Required by the ArrayAccess implementation415 *416 * @param int $offset417 * @param array $value418 */419 public function offsetSet($offset, $value)420 {421 $this->set($offset, $value);422 }423 /**424 * Proxy to {@see remove()}425 * Required by the ArrayAccess implementation426 *427 * @param int $offset428 */429 public function offsetUnset($offset)430 {431 $this->remove($offset, 1);432 }433 /**434 * Sets the default case fold435 *436 * @param string $caseFold437 */438 public static function setDefaultCaseFold($caseFold)439 {440 self::$_defaultCaseFold = self::_sanitizeCaseFold($caseFold, self::ATTR_CASEFOLD_NONE);441 }442 /**443 * Sanitizes the case fold444 *445 * @param string $caseFold446 * @return string447 */448 protected static function _sanitizeCaseFold($caseFold, $default)449 {450 switch ($caseFold) {451 case self::ATTR_CASEFOLD_NONE:452 case self::ATTR_CASEFOLD_UPPER:453 case self::ATTR_CASEFOLD_LOWER:454 return $caseFold;455 break;456 default:457 return $default;...

Full Screen

Full Screen

fold

Using AI Code Generation

copy

Full Screen

1require_once 'atoum\atoum\classes\test.php';2require_once 'atoum\atoum\classes\test\adapter.php';3require_once 'atoum\atoum\classes\test\adapter\invoker.php';4require_once 'atoum\atoum\classes\test\adapter\invoker\aggregator.php';5require_once 'atoum\atoum\classes\test\adapter\invoker\exception.php';6require_once 'atoum\atoum\classes\test\adapter\invoker\mock.php';7require_once 'atoum\atoum\classes\test\adapter\invoker\php\cast.php';8require_once 'atoum\atoum\classes\test\adapter\invoker\php\constant.php';9require_once 'atoum\atoum\classes\test\adapter\invoker\php\function.php';10require_once 'atoum\atoum\classes\test\adapter\invoker\php\method.php';11require_once 'atoum\atoum\classes\test\adapter\invoker\php\static\method.php';12require_once 'atoum\atoum\classes\test\adapter\invoker\reflection\class\constant.php';13require_once 'atoum\atoum\classes\test\adapter\invoker\reflection\class\method.php';14require_once 'atoum\atoum\classes\test\adapter\invoker\reflection\class\property.php';15require_once 'atoum\atoum\classes\test\adapter\invoker\reflection\constant.php';16require_once 'atoum\atoum\classes\test\adapter\invoker\reflection\function.php';17require_once 'atoum\atoum\classes\test\adapter\invoker\reflection\method.php';18require_once 'atoum\atoum\classes\test\adapter\invoker\reflection\property.php';19require_once 'atoum\atoum\classes\test\adapter\invoker\reflection\static\method.php';20require_once 'atoum\atoum\classes\test\adapter\invoker\reflection\static\property.php';

Full Screen

Full Screen

fold

Using AI Code Generation

copy

Full Screen

1require_once 'atoum\atoum\classes\asserter\generator.php';2require_once 'atoum\atoum\classes\test.php';3require_once 'atoum\atoum\classes\test\adapter.php';4require_once 'atoum\atoum\classes\test\adapter\invoker.php';5require_once 'atoum\atoum\classes\test\adapter\invoker\aggregator.php';6require_once 'atoum\atoum\classes\test\adapter\invoker\aggregator\iterator.php';7require_once 'atoum\atoum\classes\test\adapter\invoker\aggregator\iterator\adapter.php';8require_once 'atoum\atoum\classes\test\adapter\invoker\aggregator\iterator\adapter\invoker.php';9require_once 'atoum\atoum\classes\test\adapter\invoker\aggregator\iterator\adapter\invoker\exception.php';10require_once 'atoum\atoum\classes\test\adapter\invoker\aggregator\iterator\adapter\invoker\exception\invalid\type.php';11require_once 'atoum\atoum\classes\test\adapter\invoker\aggregator\iterator\adapter\invoker\exception\invalid\value.php';12require_once 'atoum\atoum\classes\test\adapter\invoker\aggregator\iterator\adapter\invoker\exception\invalid\argument.php';13require_once 'atoum\atoum\classes\test\adapter\invoker\aggregator\iterator\adapter\invoker\exception\invalid\argument\type.php';14require_once 'atoum\atoum\classes\test\adapter\invoker\aggregator\iterator\adapter\invoker\exception\invalid\argument\value.php';15require_once 'atoum\atoum\classes\test\adapter\invoker\aggregator\iterator\adapter\invoker\exception\invalid\argument\count.php';16require_once 'atoum\atoum\classes\test\adapter\invoker\aggregator\iterator\adapter\invoker\exception\invalid\argument\range.php';

Full Screen

Full Screen

fold

Using AI Code Generation

copy

Full Screen

1require_once 'atoum.php';2$test = new test();3$test->run();4require_once 'atoum.php';5$test = new test();6$test->run();

Full Screen

Full Screen

fold

Using AI Code Generation

copy

Full Screen

1$fold = new \mageekguy\atoum\report\fields\runner\tests\coverage\html\fold('path/to/1.php', 1, 2, 3, 4);2$fold = new \mageekguy\atoum\report\fields\runner\tests\coverage\html\fold('path/to/1.php', 1, 2, 3, 4);3$fold = new \mageekguy\atoum\report\fields\runner\tests\coverage\html\fold('path/to/2.php', 1, 2, 3, 4);4$fold = new \mageekguy\atoum\report\fields\runner\tests\coverage\html\fold('path/to/2.php', 1, 2, 3, 4);5$fold = new \mageekguy\atoum\report\fields\runner\tests\coverage\html\fold('path/to/3.php', 1, 2, 3, 4);6$fold = new \mageekguy\atoum\report\fields\runner\tests\coverage\html\fold('path/to/3.php', 1, 2, 3, 4);7$fold = new \mageekguy\atoum\report\fields\runner\tests\coverage\html\fold('path/to/4.php', 1, 2, 3, 4);8$fold = new \mageekguy\atoum\report\fields\runner\tests\coverage\html\fold('path/to/4.php', 1, 2, 3, 4);

Full Screen

Full Screen

fold

Using AI Code Generation

copy

Full Screen

1$fold = new fold();2$fold->fold('1.php');3$fold = new fold();4$fold->fold('2.php');5$fold = new fold();6$fold->fold('3.php');7$fold = new fold();8$fold->fold('4.php');9$fold = new fold();10$fold->fold('5.php');11$fold = new fold();12$fold->fold('6.php');13$fold = new fold();14$fold->fold('7.php');15$fold = new fold();16$fold->fold('8.php');17$fold = new fold();18$fold->fold('9.php');19$fold = new fold();20$fold->fold('10.php');21$fold = new fold();22$fold->fold('11.php');23$fold = new fold();24$fold->fold('12.php');

Full Screen

Full Screen

fold

Using AI Code Generation

copy

Full Screen

1use atoum\test;2use atoum\test\path;3use atoum\test\path\class;4use atoum\test\path\class\constant;5use atoum\test\path\class\method;6use atoum\test\path\class\property;7use atoum\test\path\class\method\parameter;8use atoum\test\path\class\method\parameter\type;9use atoum\test\path\class\method\return;10use atoum\test\path\class\method\return\type;11use atoum\test\path\class\method\visibility;12use atoum\test\path\class\method\visibility\type;13use atoum\test\path\class\method\visibility\type\static;14use atoum\test\path\class\method\visibility\type\final;15use atoum\test\path\class\method\visibility\type\abstract;16use atoum\test\path\class\method\visibility\type\final\abstract;17use atoum\test\path\class\method\visibility\type\final\abstract\static;18use atoum\test\path\class\method\visibility\type\final\abstract\static\visibility;19use atoum\test\path\class\method\visibility\type\final\abstract\static\visibility\type;20use atoum\test\path\class\method\visibility\type\final\abstract\static\visibility\type\final;

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in fold

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful