arielenter / laravel-code-snippets
Collection of little helpers neither big nor relevant enough to be their own packages.
Installs: 4
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/arielenter/laravel-code-snippets
Requires
- arielenter/laravel-test-translations: ^1.5
- laravel/laravel: ^12.4
Requires (Dev)
Suggests
- arielenter/laravel-test-translations: If available, 'createReadmeFromTemplate' will test that all placeholders present in the 'readme' template have been accounted by the replace values given.
README
Laravel Code Snippets
Collection of little helpers neither big nor relevant enough to be their own packages.
trait CreateReadme
Provides helpers to create ‘README.md’ files.
method createReadmeFromTemplate
/** * A ‘README.md’ is created using a template file for the given language. * * The function ‘trans’ or ‘__’ is used to get the resulting * ‘readme’ file. With this in mind, the template file must use placeholders * in the form of ‘:key_to_translate’ style, and the replace values have to * be given in an array where keys are the placeholders and the values are the * desired replace text. * * @param string $template Path to the template file. * @param string $locale ISO language code that the resulting * readme file is made for, using * ‘README.xx.md’ style to name it, * unless it’s equal to the * application’s current language, in * which case ‘README.md’ name is used * instead. * @param ?int $wrap If an integer is given instead of null, * the text inside the resulting * ‘readme’ file will be wrapped using * this value as the width. * @param array<string,string> $replace Replace values that will be used on the * template’s placeholders. * * @return string The generated content for the file */
method getLocaleLinks
/** * Producess the ‘md’ code corresponding to hyper links for every readme * file of every given language. * * @param array<string,string> $availableLocales ISO code as key and name as * value of every available * language. * @param string $exception Optional. ISO code of the * language we might want to leave * out. * @param string $separator Optional. Text that should * separate each link. By default * it’s ‘ | ’. * * @return string Hyper links to every README file. */
class ComposerJson
Provides helpers to perform oparations over composer’s json file.
method editKey
/** * Changes the value of the given key. If the key doesn’t exist, it will be * added. * * @param string $key Key * @param string $value Value * * @return void */
trait TestAssertion
Meant to be use on laravel’s phpunit TestCases to provide trait methods to test assertions.
method assertClosureThrowsAsserionFail
/** * Asserts that the given closure triggers an asssertion fail error. * * @param Closure $closure Closure to be tested. * @param ?string $failMsg If provided, makes sure that the expected resulting * assertion fail error throws the expected message. * * @return void */
License
GNU General Public License (GPL) version 3