PHP code example of ntentan / utils

1. Go to this page and download the library: Download ntentan/utils library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ntentan / utils example snippets


use ntentan\utils\Text;

print Text::singularize('names'); // Should output name
print Text::pluralize('pot'); // Should output pots

use ntentan\utils\Text;

print Text::camelize('home_alone'); // should output homeAlone
print Text::ucamelize('home_alone_again'); // should output HomeAloneAgain
print Text::deCamelize('HomeAloneStill'); // should output home_alone_still

use ntentan\utils\Text;

print Text::camelize('home-alone', '-'); // should output HomeAlone
print Text::deCamelize('HomeAloneAgain', '-'); // should output home-alone-again


use ntentan\utils\Filesystem;
Filesystem::directory("/path/to/some/dir")->create();

use ntentan\utils\Filesystem;
Filesystem::directory("/path/to/some/dir")->create(true);

use ntentan\utils\Filesystem;
Filesystem::directory("/path/to/some/dir")->delete();

use ntentan\utils\Filesystem;
Filesystem::directory("/path/to/some/dir")->moveTo("/path/to/new/dir");

use ntentan\utils\Filesystem;
Filesystem::directory("/path/to/some/dir")->copyTo("/path/to/new/dir");

use ntentan\utils\Filesystem;
Filesystem::file("/path/to/some/file")->moveTo("/path/to/new/file");

use ntentan\utils\Validator;

$validator = new Validator();
$validator->setRules(['

$data = ['name' => 'Kofi', 'email' => '[email protected]'];
$success = $validator->validate($data);

$data = ['email' => '[email protected]'];
if(!$validator->validate($data)) {
    print_r($validator->getInvalidFields());
}