PHP Classes

File: vendor/illuminate/collections/functions.php

Recommend this page to a friend!
  Packages of OmDiaries   Laravel AI Email Assistant   vendor/illuminate/collections/functions.php   Download  
File: vendor/illuminate/collections/functions.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Laravel AI Email Assistant
Generate an email message with the OpenAI GPT API
Author: By
Last change:
Date: 4 months ago
Size: 687 bytes
 

Contents

Class file image Download
<?php

namespace Illuminate\Support;

if (!
function_exists('Illuminate\Support\enum_value')) {
   
/**
     * Return a scalar value for the given value that might be an enum.
     *
     * @internal
     *
     * @template TValue
     * @template TDefault
     *
     * @param TValue $value
     * @param TDefault|callable(TValue): TDefault $default
     * @return ($value is empty ? TDefault : mixed)
     */
   
function enum_value($value, $default = null)
    {
        return
match (true) {
           
$value instanceof \BackedEnum => $value->value,
           
$value instanceof \UnitEnum => $value->name,

            default =>
$value ?? value($default),
        };
    }
}