Overview

Namespaces

  • chippyash
    • Type
      • Exceptions
      • Interfaces
      • Number
        • Complex
        • Rational
      • String

Classes

  • AbstractMultiValueType
  • AbstractType
  • AbstractTypeFactory
  • BoolType
  • TypeFactory
  • Overview
  • Namespace
  • Class
  • Tree

Class TypeFactory

Static Factory for creating types

chippyash\Type\AbstractTypeFactory
Extended by chippyash\Type\TypeFactory
Abstract
Namespace: chippyash\Type
Located at TypeFactory.php
Methods summary
public static
# setNumberType( string $requiredType )

Set the required number type to return By default this is self::TYPE_DEFAULT which is 'auto', meaning that the factory will determine if GMP is installed and use that else use PHP native types

Set the required number type to return By default this is self::TYPE_DEFAULT which is 'auto', meaning that the factory will determine if GMP is installed and use that else use PHP native types

Parameters

$requiredType

Throws

InvalidArgumentException
\InvalidArgumentException

Overrides

chippyash\Type\AbstractTypeFactory::setNumberType()
public static chippyash\Type\AbstractType
# create( string $type, mixed $value, mixed $extra = null )

Generic type factory

Generic type factory

Parameters

$type
$value
$extra
required for some types

Returns

chippyash\Type\AbstractType
\chippyash\Type\AbstractType

Throws

chippyash\Type\Exceptions\InvalidTypeException
InvalidTypeException
public static chippyash\Type\Number\IntType
# createInt( mixed $value )

Create an IntType

Create an IntType

Parameters

$value

Returns

chippyash\Type\Number\IntType
\chippyash\Type\Number\IntType

Throws

InvalidArgumentException
\InvalidArgumentException
public static chippyash\Type\Number\FloatType|chippyash\Type\Number\Rational\GMPRationalType
# createFloat( mixed $value )

Create a FloatType

Create a FloatType

Parameters

$value

Returns

chippyash\Type\Number\FloatType|chippyash\Type\Number\Rational\GMPRationalType
\chippyash\Type\Number\FloatType|\chippyash\Type\Number\Rational\GMPRationalType

Throws

InvalidArgumentException
\InvalidArgumentException
public static chippyash\Type\String\StringType
# createString( mixed $value )

Create a StringType

Create a StringType

Parameters

$value

Returns

chippyash\Type\String\StringType
\chippyash\Type\String\StringType
public static chippyash\Type\BoolType
# createBool( mixed $value )

Create a BoolType

Create a BoolType

Parameters

$value

Returns

chippyash\Type\BoolType
\chippyash\Type\BoolType
public static chippyash\Type\String\DigitType
# createDigit( mixed $value )

Create a DigitType

Create a DigitType

Parameters

$value

Returns

chippyash\Type\String\DigitType
\chippyash\Type\String\DigitType
public static chippyash\Type\Number\Complex\ComplexType
# createComplex( integer|float|string|chippyash\Type\Interfaces\NumericTypeInterface $realPart, integer|float|string|chippyash\Type\Interfaces\NumericTypeInterface|null $imaginaryPart = null )

Create a Complex number If imaginary part is null, a complex equivalent real number is created r+0i

Create a Complex number If imaginary part is null, a complex equivalent real number is created r+0i

Parameters

$realPart
$imaginaryPart

Returns

chippyash\Type\Number\Complex\ComplexType
\chippyash\Type\Number\Complex\ComplexType
public static chippyash\Type\Number\Rational\RationalType
# createRational( integer|string|float $numerator, integer $denominator = 1 )

Create a Rational number

Create a Rational number

Parameters

$numerator
$denominator

Returns

chippyash\Type\Number\Rational\RationalType
\chippyash\Type\Number\Rational\RationalType

See

RationalTypeFactory::create
public static chippyash\Type\Number\WholeIntType|chippyash\Type\Number\GMPIntType
# createWhole( mixed $value )

Create a whole number

Create a whole number

Parameters

$value

Returns

chippyash\Type\Number\WholeIntType|chippyash\Type\Number\GMPIntType
\chippyash\Type\Number\WholeIntType|\chippyash\Type\Number\GMPIntType

Throws

InvalidArgumentException
\InvalidArgumentException
public static chippyash\Type\Number\NaturalIntType|chippyash\Type\Number\GMPIntType
# createNatural( mixed $value )

Create a Natural number

Create a Natural number

Parameters

$value

Returns

chippyash\Type\Number\NaturalIntType|chippyash\Type\Number\GMPIntType
\chippyash\Type\Number\NaturalIntType|\chippyash\Type\Number\GMPIntType

Throws

InvalidArgumentException
\InvalidArgumentException
Constants inherited from chippyash\Type\AbstractTypeFactory
TYPE_DEFAULT, TYPE_GMP, TYPE_NATIVE
Chippyash Strong Types API documentation generated by ApiGen 2.8.0