src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php
public static function create($realPart, $imaginaryPart = null)
    {
        if (is_string($realPart)) {
            return self::fromString($realPart);
        }

        if ($realPart instanceof ComplexType) {
            return clone $realPart;
        }

        if (is_null($imaginaryPart)) {
            $imaginaryPart = 0;
        }

        $real = self::convertType($realPart);
        $imaginary = self::convertType($imaginaryPart);
        
        if (self::getRequiredType() == self::TYPE_GMP) {
            // @codeCoverageIgnoreStart
            return new GMPComplexType($real, $imaginary);
            // @codeCoverageIgnoreEnd
        }
        
        return new ComplexType($real, $imaginary);
    }
public static function create($realPart, $imaginaryPart = null)
    {
        if (is_string($realPart)) {
            return self::fromString($realPart);
        }

        if ($realPart instanceof ComplexType) {
            return clone $realPart;
        }

        if (is_null($imaginaryPart)) {
            $imaginaryPart = 0;
        }

        $real = self::convertType($realPart);
        $imaginary = self::convertType($imaginaryPart);
        
        if (self::getRequiredType() == self::TYPE_GMP) {
            // @codeCoverageIgnoreStart
            return new GMPComplexType($real, $imaginary);
            // @codeCoverageIgnoreEnd
        }
        
        return new ComplexType($real, $imaginary);
    }
public static function create ( $ realPart , $ imaginaryPart = null ) { if ( is_string ( $ realPart ) ) { return self :: fromString ( $ realPart ) ; } if ( $ realPart instanceof ComplexType ) { return clone $ realPart ; } if ( is_null ( $ imaginaryPart ) ) { $ imaginaryPart = 0 ; } $ real = self :: convertType ( $ realPart ) ; $ imaginary = self :: convertType ( $ imaginaryPart ) ; if ( self :: getRequiredType ( ) == self :: TYPE_GMP ) { // @codeCoverageIgnoreStart return new GMPComplexType ( $ real , $ imaginary ) ; // @codeCoverageIgnoreEnd } return new ComplexType ( $ real , $ imaginary ) ; }
Complex type factory

Construct and return a complex number. You can send in
- a string conforming to 'a+bi', 'a-bi', '-a+bi', '-a-bi' where a & b
are integer or float numbers e.g. '-12+0.67i'
- mixture of numeric (int,float,'1234' etc), IntType and FloatType corresponding to a & b

@param string|float|int|AbstractType $realPart
@param float|int|FloatType|IntType $imaginaryPart

@return \Chippyash\Type\Number\Complex\ComplexType

@throws \InvalidArgumentException
Complex type factory