├── composer.json ├── src ├── functions.php └── Neko.php ├── LICENSE.md └── README.md /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "yuloh/neko", 3 | "description": "Simple helpers for case transformations.", 4 | "require": { 5 | "php": ">=5.6.4" 6 | }, 7 | "require-dev": { 8 | "phpunit/phpunit": "^5.2" 9 | }, 10 | "license": "MIT", 11 | "authors": [ 12 | { 13 | "name": "Matt Allan", 14 | "email": "matthew.james.allan@gmail.com" 15 | } 16 | ], 17 | "autoload": { 18 | "psr-4": { 19 | "Yuloh\\Neko\\": "src" 20 | }, 21 | "files": [ 22 | "src/functions.php" 23 | ] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/functions.php: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | > of this software and associated documentation files (the "Software"), to deal 7 | > in the Software without restriction, including without limitation the rights 8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | > copies of the Software, and to permit persons to whom the Software is 10 | > furnished to do so, subject to the following conditions: 11 | > 12 | > The above copyright notice and this permission notice shall be included in 13 | > all copies or substantial portions of the Software. 14 | > 15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | > THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Neko - Case tranformation functions for PHP 2 | 3 | Neko is a small collection of case tranformation functions for PHP. They are as simple as possible with no external dependencies. 4 | 5 | I wrote this library because I was tired of the other libraries out there not working like I expected. Neko can handle input in Title case, lower case, PascalCase, camelCase, kebab-case, SCREAMING-KEBAB-CASE, snake_case, and SCREAMING_SNAKE_CASE. 6 | 7 | You can see how Neko stacks up against other case transformation libraries in the throwdown [over here](https://github.com/yuloh/case-transform-tests). 8 | 9 | ## Install 10 | 11 | Neko can be installed using [composer](getcomposer.org). 12 | 13 | ``` bash 14 | $ composer require yuloh/neko 15 | ``` 16 | 17 | ## Usage 18 | 19 | ### Snake Case 20 | 21 | ```php 22 | use function Yuloh\Neko\snake_case; 23 | 24 | echo snake_case('Hello World'); // hello_world 25 | ``` 26 | 27 | ### Kebab Case 28 | 29 | ```php 30 | use function Yuloh\Neko\kebab_case; 31 | 32 | echo kebab_case('Hello World'); // hello-world 33 | ``` 34 | 35 | ### Pascal Case 36 | 37 | ```php 38 | use function Yuloh\Neko\pascal_case; 39 | 40 | echo pascal_case('Hello World'); // HelloWorld 41 | ``` 42 | 43 | ### Camel Case 44 | 45 | ```php 46 | use function Yuloh\Neko\camel_case; 47 | 48 | echo camel_case('Hello World'); //helloWorld 49 | ``` 50 | -------------------------------------------------------------------------------- /src/Neko.php: -------------------------------------------------------------------------------- 1 |