Helpers Usage

Usage

Work in progress

    /**
     * Converts an integer number of minutes into duration string.
     * Returns time format H:i from minutes.
     * Formats returned HH:MM, HHH:MM, HH, or HHH.
     *
     * @param  int|float $minutes
     * @param  bool      $abbreviate
     * @return string
     */
    minutes_to_duration(int|float $minutes, bool $abbreviate = false)
    /**
     * Transform time into minutes.
     * Seconds are not counted.
     * Returns minutes from time format H:i:s|H:i
     *
     * @param  \DateTimeInterface|string  $time
     * @return int
     */
    time_to_minutes(\DateTimeInterface|string $time)
    /**
     * Converts an integer number of minutes into hours string.
     * Returns time format H from minutes.
     * Formats returned HH, or HHH.
     *
     * @param  int|float $minutes
     * @param  bool      $abbreviate
     * @return string
     */
    minutes_to_hours(int|float $minutes, bool $abbreviate = false)
    /**
     * Returns the sum of times.
     *
     * @param  array  $entitiy
     * @param  bool   $carbon
     * @return string
     */
    sum_time(array $entitiy, bool $carbon = false)
    /**
     * Transform H:i format time to decimal time.
     * Seconds are not counted.
     * Ex 01:30 worked hours into 1.30
     *
     * @param  \DateTimeInterface|string|int  $time / in format H:i:s or H:i
     * @param  bool   $transform
     * @return float
    */
    to_decimal_time(\DateTimeInterface|string|int $time, bool $transofrm = false)
    /**
     * Used to check text-based user input.
     * We identify these parts by 3 "stop sign" emojis (aka "octagonal sign" U+1F6D1).
     *
     * @param  string $text
     * @param  string|null $template
     * @return bool
     */
    valid_template_text(string $text, string $template = '🛑🛑🛑')
    /**
     * Is used to check user input to validate a date.
     *
     * @param  \DateTimeInterface|string $date
     * @return bool
     */
    is_valid_date(\DateTimeInterface|string $date)
    /**
     * Is used to get package version.
     *
     * @param  string $package
     * @return string|null
     */
    get_package_version($package)
    /**
     * Is used to check if package is installed.
     *
     * @param  string $package
     * @return bool
     */
    has_package($package)
    /**
     * Convert stdClass Object to Array.
     *
     * @param  $data
     * @return array
     */
    object_to_array($data)
    /**
     * Convert Array to stdClass Object.
     *
     * @param  $data
     * @return object
     */
    array_to_object($data)
    /**
     * Counts all elements in an array or in a object.
     *
     * @param  array|object $data
     * @return int
     */
    count_values(array|object $data)