public function testTitleizeCamelSplit() { $expectations = [["first name", "First Name"], ["first_name", "First Name"], ["firstName", "First Name"]]; foreach ($expectations as $expect) { $this->assertEquals($expect[1], \Packaged\Helpers\Strings::titleize($expect[0], true)); } }
/** * @return ISafeHtmlProducer */ public function render() { $output = new Div(); $groups = $this->getMethods(); foreach ($groups as $group => $methods) { $output->appendContent(Div::create(new HeadingOne(Strings::titleize($group)))->addClass('content-container')); foreach ($methods as $method) { $reflect = new \ReflectionMethod($this, $method); $parsed = DocBlockParser::fromMethod($this, $method); $code = $this->_getCode($reflect); $id = Strings::randomString(4); $toggledCode = new Div(); $toggledCode->appendContent(new HeadingFour((new Link('#', Strings::titleize($method)))->setAttribute('onclick', '$(\'#code-' . $id . '\')' . '.toggleClass(\'' . Ui::HIDE . '\');' . 'return false;'))); $code = new SafeHtml(str_replace('<span style="color: #0000BB"><?php </span>', '', highlight_string('<?php ' . $code, true))); $toggledCode->appendContent(Div::create()->appendContent(HtmlTag::createTag('pre', [], $code))->addClass(Ui::HIDE)->setId('code-' . $id)); $methRow = Div::create()->addClass('content-container'); $methRow->appendContent($toggledCode); $methRow->appendContent(new Paragraph($parsed->getSummary())); $methRow->appendContent($this->{$method}()); $output->appendContent($methRow); } } return $output; }
/** * Retrieve the name for this endpoint * * @return string */ public function getName() { return Strings::titleize(Objects::classShortname(get_called_class())); }