/** * Let's do this ... * @param $template string The path or url to a tasty cheesecake template * @param $params array Optional parameters that are merged with existing * params from a cheesecake.json file :O * @param $options array Options */ public function __construct($template, array $params = [], array $options = []) { $this->template = $template; $this->templateType = $this->detectTemplateType($template); $this->params = $params; $this->output = $this->getoa($options, self::OPT_OUTPUT, '.'); $this->noInteraction = $this->getoa($options, self::OPT_NO_INTERACTION, false); $options = ['pragmas' => [\Mustache_Engine::PRAGMA_FILTERS]]; $this->mustache = new \Mustache_Engine($options); $this->mustache->addHelper('string', ['toLowerCase' => function ($value) { return Stringy::toLowerCase($value); }, 'toUpperCase' => function ($value) { return Stringy::toUpperCase($value); }, 'upperCaseFirst' => function ($value) { return Stringy::upperCaseFirst($value); }, 'lowerCaseFirst' => function ($value) { return Stringy::lowerCaseFirst($value); }, 'humanize' => function ($value) { return Stringy::humanize($value); }, 'camelize' => function ($value) { return Stringy::camelize($value); }, 'upperCamelize' => function ($value) { return Stringy::upperCamelize($value); }, 'slugify' => function ($value) { return Stringy::slugify($value); }]); $this->fs = new Filesystem(); }
/** * @param string $rawName * @param \stdClass $boundary */ public function importFilter($rawName, $boundary) { $name = S::camelize($rawName); $boundary = (array) $boundary; $isRanged = false; $title = S::humanize($rawName); if (isset($boundary['max']) || isset($boundary['min'])) { $isRanged = true; } $filterData = ['name' => $name, 'isRanged' => $isRanged, 'title' => $title, 'values' => $boundary]; $this->filters[] = $filterData; }
?> </div> <?php if (isset($bootstrapTime)) { ?> <div>Application Bootstrap Time: <?php echo $bootstrapTime; ?> </div> <?php } ?> <?php if (!empty($timers)) { foreach ($timers as $name => $value) { ?> <div><?php echo \Stringy\StaticStringy::humanize($name); ?> : <?php echo $value; ?> </div> <?php } } ?> </small>
/** * @dataProvider humanizeProvider() */ public function testHumanize($expected, $str, $encoding = null) { $result = S::humanize($str, $encoding); $this->assertInternalType('string', $result); $this->assertEquals($expected, $result); }
<table class="table table-bordered table-striped"> <?php /** @var TemplateView $component */ use Stringy\StaticStringy; use ViewComponents\ViewComponents\Component\TemplateView; foreach ($component->getData() as $key => $value) { ?> <?php if (is_object($value) && !method_exists($value, '__toString')) { continue; } ?> <tr> <td><?php echo StaticStringy::humanize($key); ?> </td> <td><?php if (is_array($value)) { $view = new TemplateView($component->getTemplateName(), $value, $component->getRenderer()); echo $view->render(); } else { echo $value; } ?> </td> </tr> <?php } ?>
public function humanize($string) { return Stringy::humanize($string); }
public function getName() { return $this->name ?: StaticStringy::humanize($this->getColumn()); }
protected function setViewData() { $view = $this->getView(); if (!$view instanceof TemplateView) { return; } $defaults = ['containerAttributes' => ['data-role' => 'control-container', 'data-control' => 'filter'], 'inline' => true, 'label' => StaticStringy::humanize($this->field)]; if ($this->valueOption !== null) { $defaults['name'] = $this->valueOption->getKey(); $defaults['value'] = $this->valueOption->getValue(); } $view->setDefaultData($defaults); }