本文整理汇总了PHP中camel_case函数的典型用法代码示例。如果您正苦于以下问题:PHP camel_case函数的具体用法?PHP camel_case怎么用?PHP camel_case使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了camel_case函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createEntity
/**
* @param array $data
* @return CampaignEmail
*/
public function createEntity($data = array())
{
$final = [];
foreach ($data as $key => $value) {
$newKey = camel_case($key);
// sort out dates
if ($newKey == 'createdAt') {
$value = new DateTime($value);
}
if ($newKey == 'updatedAt') {
$value = new DateTime($value);
}
// sort out emails
if ($newKey == 'emailAddress') {
$value = new Email($value);
}
if ($newKey == 'variables') {
if (!is_array($value)) {
$value = json_decode($value, true);
}
}
$final[$newKey] = $value;
}
return new CampaignEmail($final);
}
示例2: __get
/**
* Map to get.
*
* @param $name
* @return mixed
*/
public function __get($name)
{
if ($this->has($name)) {
return $this->get($name);
}
return call_user_func([$this, camel_case($name)]);
}
示例3: build
/**
* @param \stdClass|array $parameters
*/
public function build($parameters)
{
foreach ($parameters as $property => $value) {
$property = camel_case($property);
$this->{$property} = $value;
}
}
示例4: geoip
/**
* Get an instance of the current geoip.
*
* @return \PulkitJalan\GeoIP\GeoIP
*/
function geoip($key = null)
{
if (is_null($key)) {
return app('geoip');
}
return app('geoip')->{'get' . ucwords(camel_case($key))}();
}
示例5: render
/**
* Render a Field.
*
* @param string $type
* @param string $attribute
* @param string $field
* @param string $options
*
* @return \Illuminate\Http\Response
*/
public function render($action, $type, $attribute, $value = null, $options = [])
{
if (!isset($type)) {
throw new \Exception('Field Type cannot be empty or undefined.');
}
return call_user_func_array([$this->create($type, $attribute, $value, $options), camel_case('render_' . $action)], []);
}
示例6: doGenerateMethods
private function doGenerateMethods()
{
$methodPostfix = ucfirst(camel_case(preg_replace('~2~', '_to_', $this->table)));
$this->info('Routes:');
$getRoute = "Route::get('" . $this->trimAdminPrefix($this->getRequestUri) . "', 'TableAdminController@show" . $methodPostfix . "');";
$postRoute = "Route::post('" . $this->trimAdminPrefix($this->postRequestUri) . "', 'TableAdminController@handle" . $methodPostfix . "');";
$this->line($getRoute);
$this->line($postRoute);
$this->info('Methods:');
$showMethod = 'public function show' . $methodPostfix . '()' . PHP_EOL;
$showMethod .= '{' . PHP_EOL;
$showMethod .= ' $options = array(' . PHP_EOL;
$showMethod .= " 'url' => '" . $this->getRequestUri . "'," . PHP_EOL;
$showMethod .= " 'def_name' => '" . $this->definition . "'," . PHP_EOL;
$showMethod .= ' );' . PHP_EOL;
$showMethod .= ' list($table, $form) = Jarboe::table($options);' . PHP_EOL . PHP_EOL;
$showMethod .= " return View::make('admin::table', compact('table', 'form'));" . PHP_EOL;
$showMethod .= '} // end show' . $methodPostfix . PHP_EOL . PHP_EOL;
echo $showMethod;
$postMethod = 'public function handle' . $methodPostfix . '()' . PHP_EOL;
$postMethod .= '{' . PHP_EOL;
$postMethod .= ' $options = array(' . PHP_EOL;
$postMethod .= " 'url' => '" . $this->getRequestUri . "'," . PHP_EOL;
$postMethod .= " 'def_name' => '" . $this->definition . "'," . PHP_EOL;
$postMethod .= ' );' . PHP_EOL . PHP_EOL;
$postMethod .= ' return Jarboe::table($options);' . PHP_EOL;
$postMethod .= '} // end handle' . $methodPostfix . PHP_EOL;
echo $postMethod;
}
示例7: handle
public function handle()
{
if ($this->option('only-state')) {
$this->input->setOption('template', 0);
$this->input->setOption('controller', 0);
$this->input->setOption('abstract', 1);
}
$state = $this->argument('state');
$abstractOption = $this->option('abstract');
$templateOption = $this->option('template');
$controllerOption = $this->option('controller');
$statePieces = explode('.', $state);
$path = 'src/application/' . str_replace('.', '/', $state);
$absolutePath = public_path($path);
$controller = implode(array_map(function ($piece) {
return ucfirst(camel_case($piece));
}, $statePieces)) . 'Ctrl';
$name = end($statePieces);
$variables = compact('name', 'state', 'absolutePath', 'path', 'controller', 'abstractOption', 'templateOption', 'controllerOption');
if (!file_exists($absolutePath) && $this->confirm('The folder does not exist, shall I create it?')) {
mkdir($absolutePath);
}
$this->make('.html', $variables);
$this->make('.controller.js', $variables);
$this->make('.state.js', $variables);
}
示例8: apply
public function apply($builder, RepositoryInterface $repository)
{
$fieldsSearchable = $repository->getFieldsSearchable();
$search = $this->request->get(config('repository.criteria.params.search', 'search'), null);
$searchFields = $this->request->get(config('repository.criteria.params.searchFields', 'searchFields'), null);
$filter = $this->request->get(config('repository.criteria.params.filter', 'filter'), null);
$orderBy = $this->request->get(config('repository.criteria.params.orderBy', 'orderBy'), null);
$sortedBy = $this->request->get(config('repository.criteria.params.sortedBy', 'sortedBy'), 'asc');
$sortedBy = !empty($sortedBy) ? $sortedBy : 'asc';
if ($search && is_array($fieldsSearchable) && count($fieldsSearchable)) {
$searchFields = is_array($searchFields) || is_null($searchFields) ? $searchFields : explode(';', $searchFields);
$fields = $this->parserFieldsSearch($fieldsSearchable, $searchFields);
$isFirstField = true;
$searchData = $this->parserSearchData($search);
$search = $this->parserSearchValue($search);
$modelForceAndWhere = false;
$builder = $builder->where(function ($query) use($fields, $search, $searchData, $isFirstField, $modelForceAndWhere) {
foreach ($fields as $field => $condition) {
if (is_numeric($field)) {
$field = $condition;
$condition = '=';
}
$value = null;
$condition = trim(strtolower($condition));
if (isset($searchData[$field])) {
$value = $condition == 'like' ? "%{$searchData[$field]}%" : $searchData[$field];
} else {
if (!is_null($search)) {
$value = $condition == 'like' ? "%{$search}%" : $search;
}
}
if ($isFirstField || $modelForceAndWhere) {
if (!is_null($value)) {
$query->where($field, $condition, $value);
$isFirstField = false;
}
} else {
if (!is_null($value)) {
$query->orWhere($field, $condition, $value);
}
}
}
});
}
if (isset($orderBy) && in_array(strtolower($sortedBy), ['asc', 'desc'])) {
$builder = $builder->orderBy($orderBy, $sortedBy);
}
if (isset($filter) && !empty($filter)) {
if (is_string($filter)) {
foreach (array_unique(explode(',', $filter)) as $filter) {
// eg. filter 'hot' 会调用方法 'filterHot'
$method_name = camel_case('filter_' . $filter);
if (method_exists($this, $method_name)) {
$builder = call_user_func([$this, $method_name], $builder);
}
}
}
}
return $builder;
}
示例9: create
/**
* Create a new form.
*
* @param string $model
* @param array $columns
* @param string $view
* @return void
*/
public function create($model, $columns = [], $view = 'form')
{
$model = $this->sanitize($model);
$this->writeLangFiles($columns, $model);
$stub = $this->getStub('form.blade.stub');
$el = [];
foreach ($columns as $col) {
$col['field'] = $this->sanitize($col['field'], '/[^a-zA-Z0-9_-]/');
switch ($col['type']) {
case 'text':
case 'mediumText':
case 'longText':
$inputStub = $this->getStub('form-textarea.stub');
break;
case 'boolean':
case 'tinyInteger':
$inputStub = $this->getStub('form-checkbox.stub');
break;
case 'string':
default:
$inputStub = $this->getStub('form-input.stub');
break;
}
$el[] = $this->prepare($inputStub, ['field_name' => $col['field'], 'camel_model' => camel_case(strtolower($model)), 'plural_lower_model' => strtolower(Str::plural($model))]);
}
$content = $this->prepare($stub, ['columns' => implode("\n\t\t\t\t", $el), 'camel_model' => camel_case(strtolower($model)), 'plural_lower_model' => strtolower(Str::plural($model))]);
$filePath = $this->path . '/themes/admin/default/packages/' . $this->extension->lowerVendor . '/' . $this->extension->lowerName . '/views/' . Str::plural(strtolower($model)) . '/';
$this->ensureDirectory($filePath);
$this->files->put($filePath . $view . '.blade.php', $content);
}
示例10: __construct
/**
* Creates a new Lavary\Menu\MenuItem instance.
*
* @param string $title
* @param string $url
* @param array $attributes
* @param int $parent
* @param \Lavary\Menu\Menu $builder
* @return void
*/
public function __construct($builder, $id, $title, $options)
{
$this->builder = $builder;
$this->id = $id;
$this->title = $title;
$this->nickname = camel_case($title);
$this->attributes = $this->builder->extractAttributes($options);
$this->parent = is_array($options) && isset($options['parent']) ? $options['parent'] : null;
// Storing path options with each link instance.
if (!is_array($options)) {
$path = array('url' => $options);
} elseif (isset($options['raw']) && $options['raw'] == true) {
$path = null;
} else {
$path = array_only($options, array('url', 'route', 'action', 'secure'));
}
if (!is_null($path)) {
$path['prefix'] = $this->builder->getLastGroupPrefix();
}
$this->link = $path ? new Link($path) : null;
// If the item's URL is the same as request URI,
// activate the item and it's parent nodes too.
if (true === \Config::get('laravel-menu::options.auto_activate')) {
if (\Request::url() == $this->url()) {
$this->activate();
}
}
}
示例11: createEntity
/**
* @param array $data
* @return Campaign
*/
public function createEntity($data = array())
{
$final = [];
foreach ($data as $key => $value) {
$newKey = camel_case($key);
// sort out dates
if ($newKey == 'createdAt') {
$value = new DateTime($value);
}
if ($newKey == 'updatedAt') {
$value = new DateTime($value);
}
// sort out emails
if ($newKey == 'fromEmail') {
$value = new Email($value);
}
if ($newKey == 'replyToEmail') {
if ($value) {
$value = new Email($value);
} else {
continue;
}
}
if ($newKey == 'bounceEmail') {
if ($value) {
$value = new Email($value);
} else {
continue;
}
}
$final[$newKey] = $value;
}
return new Campaign($final);
}
示例12: validateName
/**
* Check if name is not snake case.
*
* @param string $name
* @param string $definedClass
* @return boolean
*/
public function validateName($name, $definedClass)
{
if ($name != camel_case($name)) {
throw new Exception('Name "' . $name . '" (defined in class "' . $definedClass . '") is not a camel case name.');
}
return true;
}
示例13: setUpModel
protected function setUpModel(\Illuminate\Http\Request $request)
{
$uri = $request->route()->uri();
$modelSlug = strpos($uri, '/') ? substr($uri, 0, strpos($uri, '/')) : $uri;
$modelName = ucfirst(camel_case(str_singular($modelSlug)));
$modules = new \Ormic\Modules();
$module = $modules->getModuleOfModel($modelName);
if ($module) {
$modelClass = 'Ormic\\modules\\' . $module . '\\Model\\' . $modelName;
$viewName = snake_case($module) . '::' . snake_case($modelName) . '.' . $this->currentAction;
} else {
$modelClass = 'Ormic\\Model\\' . $modelName;
$viewName = snake_case($modelName) . '.' . $this->currentAction;
}
$this->model = new $modelClass();
$this->model->setUser($this->user);
try {
$this->view = view($viewName);
} catch (\InvalidArgumentException $ex) {
try {
$this->view = view('models.' . $this->currentAction);
} catch (\InvalidArgumentException $ex) {
// Still no view; give up.
$this->view = view();
}
}
$this->view->title = ucwords(str_replace('-', ' ', $modelSlug));
$this->view->modelSlug = $modelSlug;
$this->view->columns = $this->model->getColumns();
$this->view->record = $this->model;
}
示例14: listData
/**
* @param $query
*
* @return mixed
*/
public function listData($query)
{
foreach ($this->search as $column => $search) {
$query = $query->{'of' . ucfirst(camel_case(str_replace('.', '_', $column)))}($search);
}
return $query->orderBy($this->sort, $this->sortDirection)->select($this->tableName . '.*')->paginate($this->limit);
}
示例15: stepsBeforeFilter
public function stepsBeforeFilter(Route $route)
{
$routeStep = $this->getStepFromRoute($route);
$this->stepSessionKey($route);
$currentStep = $this->getCurrentStep();
$state = 'complete';
$this->stepsData = [];
foreach ($this->steps as $step) {
if ($step == $routeStep) {
if ($state == 'disabled') {
return $this->stepNotAllowed();
}
$class = 'active';
$state = 'disabled';
}
if ($step == $currentStep && $state != 'disabled') {
$class = 'active';
$state = 'disabled';
} elseif ($step != $routeStep) {
$class = $state;
}
$this->stepsData[$step] = ['class' => $class, 'action' => get_class() . '@get' . ucfirst(camel_case($step))];
}
$this->setCurrentStep($routeStep);
}