PHP Classes

File: src/Functions/number.php

Recommend this page to a friend!
  Classes of Axel Pardemann  >  PHP Scalar Objects  >  src/Functions/number.php  >  Download  
File: src/Functions/number.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Scalar Objects
Implement objects that behave like scalar values
Author: By
Last change:
Date: 3 years ago
Size: 500 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

namespace
NorseBlue\ScalarObjects\Functions;

use
NorseBlue\ScalarObjects\Types\FloatType;
use
NorseBlue\ScalarObjects\Types\IntType;
use
NorseBlue\ScalarObjects\Types\NumberType;

/**
 * Create a new IntType object.
 *
 * @param int|float|NumberType $value
 *
 * @return \NorseBlue\ScalarObjects\Types\NumberType
 */
function number($value = 0): NumberType
{
    if (
is_float($value)) {
        return new
FloatType($value);
    }

    return new
IntType($value);
}

For more information send a message to info at phpclasses dot org.