bagsiz/easy-functions

There is no license information available for the latest version (v1.1.2) of this package.

Laravel package for useful & easy PHP functions

v1.1.2 2019-09-09 10:34 UTC

This package is auto-updated.

Last update: 2024-10-29 05:52:54 UTC


README

Laravel package for useful & easy functions

Latest Version Build Status StyleCI Quality Score codecov Total Downloads

Installation

This package can be installed through Composer.

composer require bagsiz/easy-functions

Functions

checkFieldForRandom

This function aims to check a model's fields against a random value and return that value

Usage

For example we want to check the id fields of App\User model, you should write;

function checkUserModel() {
  $user = new User();
  $return EasyFunction::checkFieldForRandom($user, 'id', 'int', 8);
}

checkFieldForRandom($model, string $field, string $type, int $length)

  • $model = The collection of the model
  • $fiels = The field of the model -> String 'field'
  • $type = The type of value you want to generate -> String 'str' or Integer 'int'. Default 'str'
  • $length = The length of value you want to generate -> Int 8. Default 8

decimalToTime

This function aims to convert an integer with a decimal to time string

Usage

function someFunction() {
  $timeString = EasyFunction::decimalToTime(936437.85); // Should return "10:20:07:17.85"
}

decimalToTime(int $decimal)

  • $decimal = Must have a "." for decimal part. (Ex: 23.56)

Testing

./vendor/bin/phpunit