Ouzo\Utilities\Optional::of PHP Метод

of() публичный статический Метод

public static of ( $object )
    public static function of($object)
    {
        if ($object === null) {
            throw new InvalidArgumentException('Object cannot be null. Use fromNullable if you want to pass null.');
        }
        return new self($object);
    }

Usage Example

Пример #1
0
 /**
  * @test
  */
 public function shouldFlattenNullValue()
 {
     //given
     $optional = Optional::of(Optional::of(Optional::fromNullable(null)));
     //when
     $result = $optional->flatten()->orNull();
     //then
     Assert::that($result)->isNull();
 }