/** * Turns an underscore or dash separated word and turns it into a human looking string. * * @param string $str the word * @param string the separator (either _ or -) * @param bool lowercare string and upper case first * @return string the human version of given string */ public static function humanize($str, $sep = '_', $lowercase = true) { // Allow dash, otherwise default to underscore $sep = $sep != '-' ? '_' : $sep; if ($lowercase === true) { $str = \Str::ucfirst($str); } return str_replace($sep, " ", strval($str)); }
<?php if (empty($option)) { return; } Config::load('fee', true); $config = Config::get('fee'); $intervals = array(); foreach ($config['intervals'] as $interval) { $intervals[$interval] = $interval; } $interval_units = array(); foreach ($config['interval_units'] as $unit) { $interval_units[$unit] = Str::ucfirst($unit); } $name = $interval = $interval_unit = $interval_price = null; if (!empty($fee)) { $name = $fee->name; $interval = $fee->interval; $interval_unit = $fee->interval_unit; $interval_price = $fee->interval_price; } ?> <?php echo Form::open(array('class' => 'form-horizontal form-validate')); ?> <div class="control-group<?php if (!empty($errors['name'])) { echo ' error'; }
case 'active': $status_label = ' label-success'; break; case 'deleted': $status_label = ' label-important'; break; default: $status_label = ''; } ?> <span class="label<?php echo $status_label; ?> "> <?php echo Str::ucfirst($key->status); ?> </span> </td> <td> <?php if ($key->active()) { echo Html::anchor($key->link('delete'), '<i class="icon icon-remove"></i> Delete', array('class' => 'action-link confirm', 'data-msg' => "Are you sure you want to delete this API key?")); } ?> </td> </tr> <?php } ?> </tbody>
/** * Test for Str::ucfirst() * * @test */ public function test_ucfirst() { $output = Str::ucfirst('hello world'); $expected = "Hello world"; $this->assertEquals($expected, $output); }
</td> </tr> <?php echo '<?php endforeach; ?>'; ?> </tbody> </table> <?php echo '<?php else: ?>'; ?> <p>No <?php echo \Str::ucfirst($plural_name); ?> .</p> <?php echo '<?php endif; ?>'; ?> <p> <?php echo '<?php'; ?> echo Html::anchor('<?php echo $uri; ?> /create', 'Add new <?php echo \Inflector::humanize($singular_name);
case 'active': $status_label = ' label-success'; break; case 'deleted': $status_label = ' label-important'; break; default: $status_label = ''; } ?> <span class="label<?php echo $status_label; ?> "> <?php echo Str::ucfirst($customer->status); ?> </span> </td> <td> <?php echo Html::anchor($customer->link('contacts'), '<i class="icon icon-wrench"></i> Manage', array('class' => 'action-link')); ?> </td> </tr> <?php } ?> </tbody> </table>
<?php switch ($product->status) { case 'active': $status_label = ' label-success'; break; case 'canceled': default: $status_label = ''; } ?> <span class="label <?php echo $status_label; ?> "> <?php echo Str::ucfirst($product->status); ?> </span> </td> <td> <?php if ($product->active()) { echo Html::anchor($product->link('cancel'), '<i class="icon icon-remove"></i> Cancel', array('class' => 'action-link confirm', 'data-msg' => "Are you sure you want to cancel this customer's product?")); } elseif ($product->canceled()) { echo Html::anchor($product->link('activate'), '<i class="icon icon-repeat"></i> Activate', array('class' => 'action-link confirm', 'data-msg' => "Are you sure you want to activate this customer's product?")); } ?> </td> </tr> <?php }
<h2>New <span class='muted'><?php echo \Str::ucfirst($singular_name); ?> </span></h2> <br> <?php echo '<?php'; ?> echo render('<?php echo $view_path; ?> /_form'); ?> <p><?php echo '<?php'; ?> echo Html::anchor('<?php echo $uri; ?> ', 'Back'); <?php echo '?>'; ?> </p>
<h2 class="first">Editing <?php echo \Str::ucfirst($singular); ?> </h2> <?php echo '<?php'; ?> echo render('<?php echo $controller_uri; ?> /_form'); ?> <br /> <p> <?php echo '<?php'; ?> echo Html::anchor('<?php echo $controller_uri; ?> /view/'.$<?php echo $singular; ?> ->id, 'View'); <?php echo '?>'; ?> | <?php echo '<?php'; ?> echo Html::anchor('<?php
/** * Cammelcases the input string stripping underscores and spaces * @example * input_string -> inputString * input string -> inputString * inputstring -> inputstring * @param [type] $string * @return [type] */ public static function camel($string) { $tok = strtok($string, "_ "); $output = ""; while ($tok !== false) { if (empty($output)) { $output .= $tok; } else { $output .= Str::ucfirst($tok); } $tok = strtok("_ "); } return $output; }
<h2 class="first">Listing <?php echo \Str::ucfirst($plural); ?> </h2> <table cellspacing="0"> <tr> <?php foreach ($fields as $field) { ?> <th><?php echo \Inflector::humanize($field['name']); ?> </th> <?php } ?> <th></th> </tr> <?php echo '<?php'; ?> foreach ($<?php echo $plural; ?> as $<?php echo $singular; ?> ): <?php echo '?>';
switch ($option->status) { case 'active': $status_label = ' label-success'; break; case 'deleted': $status_label = ' label-important'; break; default: $status_label = ''; } ?> <span class="label<?php echo $status_label; ?> "> <?php echo Str::ucfirst($option->status); ?> </span> </td> <td><?php echo Html::anchor($option->link('edit'), '<i class="icon icon-wrench"></i> Configure', array('class' => 'action-link')); ?> </td> </tr> <?php } ?> </tbody> </table>
case 'active': $status_label = ' label-success'; break; case 'deleted': $status_label = ' label-important'; break; default: $status_label = ''; } ?> <span class="label<?php echo $status_label; ?> "> <?php echo Str::ucfirst($fee->status); ?> </span> </td> <td> <?php echo Html::anchor($fee->link('edit'), '<i class="icon icon-pencil"></i> Edit', array('class' => 'action-link')); ?> </td> </tr> <?php } ?> </tbody> </table>
<?php switch ($transaction->status) { case 'paid': $status_label = 'label-success'; break; case 'declined': $status_label = 'label-important'; break; case 'refunded': $status_label = 'label-info'; break; default: $status_label = ''; } ?> <span class="label <?php echo $status_label; ?> "> <?php echo Str::ucfirst($transaction->status); ?> </span> </td> </tr> <?php } ?> </tbody> </table>
</td> <td> <?php switch ($order->status) { case 'completed': $status_label = 'label-success'; break; case 'pending': $status_label = 'label-info'; break; case 'canceled': default: $status_label = ''; } ?> <span class="label <?php echo $status_label; ?> "> <?php echo Str::ucfirst($order->status); ?> </span> </td> </tr> <?php } ?> </tbody> </table>
<?php switch ($paymentmethod->status) { case 'active': $status_label = ' label-success'; break; case 'deleted': default: $status_label = ''; } ?> <span class="label<?php echo $status_label; ?> "> <?php echo Str::ucfirst($paymentmethod->status); ?> </span> </td> <td> <?php if ($paymentmethod->active()) { echo Html::anchor($paymentmethod->link('edit'), '<i class="icon icon-pencil"></i> Edit', array('class' => 'action-link')); if (!$paymentmethod->primary()) { echo Html::anchor($paymentmethod->link('delete'), '<i class="icon icon-remove"></i> Remove', array('class' => 'action-link confirm', 'data-msg' => "Are you sure you want to remove this customer payment method?")); } } ?> </td> </tr> <?php