public function endsWith($element) { $rep = Condition::stringOf($element); return $this->is(new Match(function ($value) use($element) { return sizeof($value) > 0 && Objects::equal($value[sizeof($value) - 1], $element); }, ['%s does not end with ' . $rep, '%s ends with ' . $rep])); }
public function get($key) { $offset = Objects::hashOf($key); if (!isset($this->elements[$offset])) { throw new \util\NoSuchElementException('No such key ' . \xp::stringOf($key)); } return $this->elements[$offset]; }
/** * Performs measurement * * @param util.profiling.Measurement $m */ public function run($m) { $m->perform(newinstance('util.profiling.Run', [], ['before' => function ($iteration) { Console::write($iteration->name(), ': '); }, 'after' => function ($result) { Console::writeLinef('%d iteration(s), %.3f seconds, result= %s', $result->iteration()->times(), $result->elapsed(), Objects::stringOf($result->result())); }])); }
/** * Load a template by a given name * * @param string $name The template name without file extension * @return io.streams.InputStream * @throws com.github.mustache.TemplateNotFoundException */ public function load($name) { $variants = $this->variantsOf($name); foreach ($variants as $variant) { if ($stream = $this->inputStreamFor($variant)) { return $stream; } } throw new TemplateNotFoundException('Cannot find template [' . implode(', ', $variants) . '] in ' . Objects::stringOf($this->base)); }
public function pop() { if (empty($this->_elements)) { throw new NoSuchElementException('Stack is empty'); } $element = array_shift($this->_elements); $h = Objects::hashOf($element); $this->_hash += HashProvider::hashOf($h); return $element; }
/** * Assertion helpeer * * @param string[] $patterns * @param unittest.assert.Value $assert * @throws unittest.AssertionFailedError */ protected function assertUnverified($patterns, $assert) { $messages = new AssertionsFailed(); $failures = $this->failed->failures(); if (sizeof($failures) !== sizeof($patterns)) { $messages->add(new AssertionFailedError(new FormattedMessage('Expected %d failures but have %d: %s', [sizeof($patterns), sizeof($failures), Objects::stringOf($failures)]))); } foreach ($failures as $i => $failure) { $message = $failure->getMessage(); if (!preg_match($patterns[$i], $message)) { $messages->add(new AssertionFailedError(new FormattedMessage('Expected `%s` to match %s', [$message, $patterns[$i]]))); } } $messages->raiseIf(); }
/** * Gets properties * * @param string $name * @return util.PropertyAccess * @throws lang.ElementNotFoundException */ public function properties($name) { $found = []; foreach ($this->sources as $source) { if ($source->provides($name)) { $found[] = $source->fetch($name); } } switch (sizeof($found)) { case 0: throw new ElementNotFoundException(sprintf('Cannot find properties "%s" in any of %s', $name, Objects::stringOf($this->sources))); case 1: return $found[0]; default: return new CompositeProperties($found); } }
/** @return string */ public function hashCode() { return crc32($this->uri) . Objects::hashOf($this->params); }
/** @return string */ public function toString() { return nameof($this) . ($this->sources ? Objects::stringOf($this->sources) : '[]'); }
/** * Creates a string representation * * @return string */ public function toString() { $params = $this->params ? Objects::stringOf($this->params) : ''; return nameof($this) . '<(' . $params . ') -> ' . $this->code . '>'; }
/** * Compare to another schema * * @param var $value * @return int */ public function compareTo($value) { return $value instanceof self ? Objects::compare($this->definition, $value->definition) : 1; }
/** * Returns whether a given comparison value is equal to this node list * * @param var $cmp * @return string */ public function equals($cmp) { return $cmp instanceof self && $this->url === $cmp->url && $this->title === $cmp->title && Objects::equal($this->text, $cmp->text); }
/** * Get string representation * * @return string */ public function toString() { return nameof($this) . '<key= ' . Objects::stringOf($this->key) . ', value= ' . Objects::stringOf($this->value) . '>'; }
/** * Creates a string representation * * @return string */ public function toString() { return nameof($this) . '@' . Objects::stringOf($this->indexed); }
/** * Returns whether another instance is equal to this * * @param var $cmp * @return bool */ public function equals($cmp) { return $cmp instanceof self && Objects::equal($this->links, $cmp->links); }
/** * Compares a given value to this * * @param var $value * @return int */ public function compareTo($value) { return $value instanceof self ? Objects::compare($this, $value) : self::$NOT_INSTANCE; }
public function update($element) { $h = $this->prefix . Objects::hashOf($element); unset($this->_elements[$h]); $this->_elements = $this->_elements + [$h => $element]; }
/** * Returns true if a given value matches this `IsEqualToArray` condition. * * @param var $value * @return bool */ public function matches($value) { return Objects::equal($this->value, $value); }
/** * Returns whether another value is equal to this * * @param var $value * @return int */ public function compareTo($value) { return $value instanceof self ? Objects::compare($this->backing, $value->backing) : 1; }
/** * Returns whether a given value is equal to this mime part * * @param var $cmp * @return bool */ public function equals($cmp) { return $cmp instanceof self && $this->contenttype === $cmp->contenttype && $this->charset === $cmp->charset && $this->encoding === $cmp->encoding && $this->disposition === $cmp->disposition && $this->name === $cmp->name && $this->filename === $cmp->filename && $this->id === $cmp->id && $this->body === $cmp->body && Objects::equal($this->headers, $cmp->headers); }
public function remove($element) { if (-1 == ($pos = $this->search($element))) { return false; } $element = $this->_elements[$pos]; $h = Objects::hashOf($element); $this->_hash -= HashProvider::hashOf($h); unset($this->_elements[$pos]); $this->_elements = array_values($this->_elements); // Re-index return true; }
/** * Check whether a given value is equal to this node list * * @param var $cmp The value * @return bool */ public function equals($cmp) { return $cmp instanceof self && $this->name === $cmp->name && $this->escape === $cmp->escape && \util\Objects::equal($this->options, $cmp->options); }
/** * Returns whether another object is equal to this * * @param lang.Generic $cmp * @return bool */ public function equals($cmp) { return $cmp instanceof self && $this->name === $cmp->name && $this->debug === $cmp->debug && $this->arguments === $cmp->arguments && $this->environment === $cmp->environment && $this->scriptlet === null ? null === $cmp->scriptlet : $this->scriptlet->equals($cmp->scriptlet) && Objects::equal($this->logLevels, $cmp->logLevels) && 0 === $this->config->compareTo($cmp->config); }
/** @return string */ public function message() { return Objects::stringOf($this->target) . ' is not equal to ' . Objects::stringOf($this->comparison); }
/** * Returns whether a given value is equal to this code unit * * @param var $cmp * @return bool */ public function equals($cmp) { return $cmp instanceof self && ($this->package === $cmp->package && Objects::equal($this->imports, $cmp->imports) && Objects::equal($this->declaration, $cmp->declaration)); }
/** * Returns whether a given value is equal to this code unit * * @param var $cmp * @return bool */ public function equals($cmp) { return $cmp instanceof self && (Objects::equal($this->parameters, $cmp->parameters) && $this->return->equals($cmp->return)); }
/** * Check whether a given value is equal to this node list * * @param var $cmp The value * @return bool */ public function equals($cmp) { return $cmp instanceof self && $this->name === $cmp->name && $this->invert === $cmp->invert && $this->start === $cmp->start && $this->end === $cmp->end && \util\Objects::equal($this->options, $cmp->options) && $this->nodes->equals($cmp->nodes); }
/** * Creates a string representation of this sequence * * @return string */ public function toString() { if ([] === $this->elements) { return nameof($this) . '<EMPTY>'; } else { return nameof($this) . '@' . Objects::stringOf($this->elements); } }
/** * Creates a string representation of any given value. * * @param var $value * @return string */ public static function stringOf($value) { return null === $value ? 'null' : Objects::stringOf($value); }
/** * Creates a string representation * * @return string */ public function toString() { return nameof($this) . '(' . Objects::stringOf($this->value) . ')'; }