The
throw_if
function throws the given exception if a given boolean expression evaluates to true
:<?php throw_if(! Auth::user()->isAdmin(), AuthorizationException::class);
throw_if(
! Auth::user()->isAdmin(),
AuthorizationException::class,
'You are not allowed to access this page.'
);
<?php try {
return $this->driver->read($path);
} catch (UnableToReadFile $e) {
throw_if($this->throwsExceptions(), $e);
}
}
<?php ? $this->driver->writeStream($path, $contents, $options)
: $this->driver->write($path, $contents, $options);
} catch (UnableToWriteFile|UnableToSetVisibility $e) {
throw_if($this->throwsExceptions(), $e);
return false;
}
<?php try {
$this->driver->setVisibility($path, $this->parseVisibility($visibility));
} catch (UnableToSetVisibility $e) {
throw_if($this->throwsExceptions(), $e);
return false;
}
<?php try {
$this->driver->delete($path);
} catch (UnableToDeleteFile $e) {
throw_if($this->throwsExceptions(), $e);
$success = false;
}
<?php try {
$this->driver->copy($from, $to);
} catch (UnableToCopyFile $e) {
throw_if($this->throwsExceptions(), $e);
return false;
}
<?php try {
$this->driver->move($from, $to);
} catch (UnableToMoveFile $e) {
throw_if($this->throwsExceptions(), $e);
return false;
}
<?php try {
return $this->driver->checksum($path, $options);
} catch (UnableToProvideChecksum $e) {
throw_if($this->throwsExceptions(), $e);
return false;
}
<?php try {
return $this->driver->mimeType($path);
} catch (UnableToRetrieveMetadata $e) {
throw_if($this->throwsExceptions(), $e);
}
return false;
<?php try {
return $this->driver->readStream($path);
} catch (UnableToReadFile $e) {
throw_if($this->throwsExceptions(), $e);
}
}
<?php try {
$this->driver->writeStream($path, $resource, $options);
} catch (UnableToWriteFile|UnableToSetVisibility $e) {
throw_if($this->throwsExceptions(), $e);
return false;
}
<?php try {
$this->driver->createDirectory($path);
} catch (UnableToCreateDirectory|UnableToSetVisibility $e) {
throw_if($this->throwsExceptions(), $e);
return false;
}
<?php try {
$this->driver->deleteDirectory($directory);
} catch (UnableToDeleteDirectory $e) {
throw_if($this->throwsExceptions(), $e);
return false;
}
<?php function throw_unless($condition, $exception = 'RuntimeException', ...$parameters)
{
throw_if(! $condition, $exception, ...$parameters);
return $condition;
}
<?php public function validate()
{
throw_if($this->fails(), $this->exception, $this);
return $this->validated();
}
<?php $this->passes();
}
throw_if($this->messages->isNotEmpty(), $this->exception, $this);
$results = [];