Webmozart\Assert\Assert::resource PHP Method

resource() public static method

public static resource ( $value, $type = null, $message = '' )
    public static function resource($value, $type = null, $message = '')
    {
        if (!is_resource($value)) {
            static::reportInvalidArgument(sprintf($message ?: 'Expected a resource. Got: %s', static::typeToString($value)));
        }
        if ($type && $type !== get_resource_type($value)) {
            static::reportInvalidArgument(sprintf($message ?: 'Expected a resource of type %2$s. Got: %s', static::typeToString($value), $type));
        }
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Creates the input.
  *
  * @param resource $stream A stream resource.
  */
 public function __construct($stream)
 {
     Assert::resource($stream, 'stream');
     $this->stream = $stream;
     // Not all streams are seekable
     @rewind($this->stream);
 }
All Usage Examples Of Webmozart\Assert\Assert::resource