src/System/Helpersinflector_helper.php

CodeIgniter

An open source application development framework for PHP

This content is released under the MIT License (MIT)

Copyright (c) 2014-2019 British Columbia Institute of Technology Copyright (c) 2019 CodeIgniter Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Functions

singular()

singular(string  $string) : string

Singular

Takes a plural word and makes it singular

Parameters

string $string

Input string

Returns

string

plural()

plural(string  $string) : string

Plural

Takes a singular word and makes it plural

Parameters

string $string

Input string

Returns

string

counted()

counted(integer  $count, string  $string) : string

Counted

Takes a number and a word to return the plural or not E.g. 0 cats, 1 cat, 2 cats, ...

Parameters

integer $count

Number of items

string $string

Input string

Returns

string

camelize()

camelize(string  $string) : string

Camelize

Takes multiple words separated by spaces or underscores and converts them to camel case.

Parameters

string $string

Input string

Returns

string

pascalize()

pascalize(string  $string) : string

Pascalize

Takes multiple words separated by spaces or underscores and converts them to Pascal case, which is camel case with an uppercase first letter.

Parameters

string $string

Input string

Returns

string

underscore()

underscore(string  $string) : string

Underscore

Takes multiple words separated by spaces and underscores them

Parameters

string $string

Input string

Returns

string

humanize()

humanize(string  $string, string  $separator = '_') : string

Humanize

Takes multiple words separated by the separator, camelizes and changes them to spaces

Parameters

string $string

Input string

string $separator

Input separator

Returns

string

is_pluralizable()

is_pluralizable(string  $word) : boolean

Checks if the given word has a plural version.

Parameters

string $word

Word to check

Returns

boolean

dasherize()

dasherize(string  $string) : string

Replaces underscores with dashes in the string.

Parameters

string $string

Input string

Returns

string

ordinal()

ordinal(integer  $integer) : string

Returns the suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.

Parameters

integer $integer

The integer to determine the suffix

Returns

string

ordinalize()

ordinalize(integer  $integer) : string

Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.

Parameters

integer $integer

The integer to ordinalize

Returns

string