/** * Checks whether both paths point to the same location * * @param Path|string $anotherPath * @return boolean true if the do, false if they don't */ public function equals($anotherPath) { $anotherPath = $anotherPath instanceof Path ? $anotherPath : new Path($anotherPath); // do something else, when path's are urls $regexp = '/^[a-zA-Z]+:\\/\\//'; $thisUrl = $this->pathname->match($regexp); $anotherUrl = $anotherPath->getPathname()->match($regexp); if ($thisUrl ^ $anotherUrl) { return false; } else { if ($thisUrl && $anotherUrl) { return $this->pathname->equals($anotherPath->getPathname()); } } return realpath($this->pathname->toString()) == realpath($anotherPath->toString()); }