Exemplo n.º 1
0
 /**
  * Returns a new Complex object from native PHP arguments.
  *
  * @param float $real Real part of the complex number
  * @param float $im   Imaginary part of the complex number
  *
  * @return Complex|ValueObjectInterface
  *
  * @throws \BadMethodCallException
  */
 public static function fromNative()
 {
     $args = \func_get_args();
     if (\count($args) != 2) {
         throw new \BadMethodCallException('You must provide 2 arguments: 1) real part, 2) imaginary part');
     }
     $real = Real::fromNative($args[0]);
     $im = Real::fromNative($args[1]);
     $complex = new self($real, $im);
     return $complex;
 }
Exemplo n.º 2
0
 public function testFromNative()
 {
     $fromNativeReal = Real::fromNative(0.056);
     $constructedReal = new Real(0.056);
     $this->assertTrue($fromNativeReal->sameValueAs($constructedReal));
 }