PHP code example of nowmovesoft / helpers

1. Go to this page and download the library: Download nowmovesoft/helpers 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/ */

    

nowmovesoft / helpers example snippets


use nms\helpers\DateHelper;

/*
 * Gets years range or one year if specified year is current.
 * For example, in 2019 it returns "2019", but in 2020 it returns "2019-2020"
 */
echo DateHelper::getYearsRange(2019);

use nms\helpers\ObjectHelper;

// instead of using tempotary variable...
$className = Module::getInstance()->useClass;
$model = new $className($paramOne, $paramTwo /* Other parameters */);

// ...you can use ObjectHelper
$model = ObjectHelper::create(Module::getInstance()->useClass, $paramOne, $paramTwo /* Other parameters */);

use nms\helpers\ObjectHelper;

// instead of this...
$result = Module::getInstance()->useClass::staticMethod($paramOne, $paramTwo /* Other parameters */);

// ...you can use ObjectHelper
$result = ObjectHelper::call(Module::getInstance()->useClass, 'staticMethod', $paramOne, $paramTwo /* Other parameters */);

use nms\helpers\ObjectHelper;

$object = new class {
    public $property = false;
};

$object = ObjectHelper::configure($object, ['property' => true]); // name-value pairs

var_dump($object->property); // true