static function href($href = null, $secure = false, $doc = true) { if (DevValue::isNotNull($href)) { $href = ''; if ($doc === false) { $href .= $_SERVER['DOCUMENT_ROOT']; } else { $protocol = $secure ? 'https' : 'http'; $href = $protocol . '://' . $_SERVER['SERVER_NAME']; $href .= $_SERVER['REQUEST_URI']; if (DevString::strrpos($href, self::PAGE_EXTENSION)) { $href = substr($href, 0, DevString::strrpos($href, self::PAGE_EXTENSION) + strlen(PAGE_EXTENSION)); } elseif (DevString::strrpos($href, '/')) { $href = substr($href, 0, DevString::strrpos($href, '/') + strlen('/')); } } } return $href; }
public function testWillNotOutputWhitespaceAtEndOfWrappedLines() { $consoleDisplay = new DevString(); $this->assertEquals(0, $consoleDisplay->getIndent()); $consoleDisplay->setWrapAt(10); $expectedString = 'this is a' . \PHP_EOL . 'long' . \PHP_EOL . 'string to' . \PHP_EOL . 'be wrapped' . \PHP_EOL; // wrap a long string $consoleDisplay->outputLine(null, 'this is a long string to be wrapped'); $output = $consoleDisplay->_getOutput(); $this->assertEquals($expectedString, $output); // what happens if we try trickle-feed the input? $consoleDisplay = new DevString(); $consoleDisplay->setWrapAt(10); $consoleDisplay->output(null, 'this is a '); $consoleDisplay->output(null, 'long '); $consoleDisplay->output(null, 'string to '); $consoleDisplay->outputLine(null, 'be wrapped'); $output = $consoleDisplay->_getOutput(); $this->assertEquals($expectedString, $output); // this problem has been seen with phix $expectedString = ' * Phix_Project\\PhixExtensions\\DummyCommandWithSwitches' . \PHP_EOL; $consoleDisplay = new DevString(); $consoleDisplay->setWrapAt(78); $consoleDisplay->setIndent(4); $consoleDisplay->output(null, '* '); $consoleDisplay->outputLine(null, 'Phix_Project\\PhixExtensions\\DummyCommandWithSwitches'); $output = $consoleDisplay->_getOutput(); $this->assertEquals($expectedString, $output); }