├── LICENSE.md ├── bootstrap └── helpers.php └── composer.json /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) Sven Luijten 4 | 5 | > 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 | -------------------------------------------------------------------------------- /bootstrap/helpers.php: -------------------------------------------------------------------------------- 1 | currentRouteName(), (array) $route) ? $positive : $negative; 22 | } 23 | } 24 | 25 | if (! function_exists('str_possessive')) { 26 | /** 27 | * Appends an apostrophe and returns the possessive form of the given 28 | * subject string. 29 | * 30 | * @param string $subject 31 | * 32 | * @return string 33 | */ 34 | function str_possessive($subject) 35 | { 36 | if (! Str::endsWith($subject, ['s', 'z', 'ch'])) { 37 | $suffix = 's'; 38 | } 39 | 40 | return $subject.'\''.($suffix ?? ''); 41 | } 42 | } 43 | 44 | if (! function_exists('pipe')) { 45 | /** 46 | * Send the given subject through a pipeline. 47 | * 48 | * @param mixed $subject 49 | * 50 | * @return \Illuminate\Pipeline\Pipeline 51 | */ 52 | function pipe($subject) 53 | { 54 | /** @var \Illuminate\Pipeline\Pipeline $pipeline */ 55 | $pipeline = app(Pipeline::class); 56 | 57 | return $pipeline->send($subject); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sven/helpers", 3 | "description": "A collection of useful helper functions for in Laravel applications.", 4 | "keywords": ["helpers", "functions", "useful", "development"], 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Sven Luijten", 9 | "email": "svenluijten1995@gmail.com", 10 | "homepage": "https://svenluijten.com" 11 | } 12 | ], 13 | "require": { 14 | "php": "^7.0", 15 | "illuminate/support": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.*" 16 | }, 17 | "require-dev": { 18 | "phpunit/phpunit": "^4.8 || ^5.0", 19 | "graham-campbell/testbench": "^3.3" 20 | }, 21 | "autoload": { 22 | "psr-4": { 23 | "Sven\\Helpers\\": "src/" 24 | }, 25 | "files": ["bootstrap/helpers.php"] 26 | }, 27 | "autoload-dev": { 28 | "psr-4": { 29 | "Sven\\Helpers\\Tests\\": "tests/" 30 | } 31 | } 32 | } 33 | --------------------------------------------------------------------------------