/** * Invert the logical meaning of this assertion * * @return bool */ public function invert() { if ($this->inverted === true) { $this->inverted = false; } else { $this->inverted = true; } // Iterate over all assertions and invert them. $iterator = $this->assertionList->getIterator(); for ($i = 0; $i < $iterator->count(); $i++) { // Get the string representation of this assertion $iterator->current()->invert(); // Move the iterator $iterator->next(); } // Now invert all combinators. foreach ($this->combinators as $key => $combinator) { if (isset($this->inversionMapping[$combinator])) { $this->combinators[$key] = $this->inversionMapping[$combinator]; } } return true; }