Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Checks if the class method exists
<?php method_exists(object|string $object_or_class, string $method): bool
<?php return $user;
}
if (method_exists($user, 'toStatamicUser')) {
return $user->toStatamicUser();
}
<?php $dispatchMethod = $this->shouldQueue
? 'dispatch'
: (method_exists(Dispatcher::class, 'dispatchSync') ? 'dispatchSync' : 'dispatchNow');
GeneratePresetImageManipulation::$dispatchMethod($asset, $preset);
<?php $command = (string) $command;
}
$process = is_string($command) && method_exists(SymfonyProcess::class, 'fromShellCommandLine')
? SymfonyProcess::fromShellCommandline($command, $path ?? $this->basePath, $this->env)
: new SymfonyProcess($command, $path ?? $this->basePath, $this->env);
<?php return $this->$method();
}
if (method_exists($this->data, $method) && collect($this->keys())->contains(Str::snake($handle))) {
return $this->wrapValue($this->data->$method(), $handle);
}
<?php private function methodExistsOnThisClass($method)
{
return method_exists($this, $method) && ! in_array($method, ['select', 'except']);
}
protected function getFromData($handle)
<?php protected function getFromData($handle)
{
$value = method_exists($this->data, 'value') ? $this->data->value($handle) : $this->data->get($handle);
if (method_exists($this->data, 'getSupplement')) {
$value = $this->data->getSupplement($handle) ?? $value;
<?php {
$value = method_exists($this->data, 'value') ? $this->data->value($handle) : $this->data->get($handle);
if (method_exists($this->data, 'getSupplement')) {
$value = $this->data->getSupplement($handle) ?? $value;
}
<?php protected function blueprintFields()
{
return (method_exists($this->data, 'blueprint') && $blueprint = $this->data->blueprint())
? $blueprint->fields()->all()
: collect();
}
<?php $method = Str::camel($sort);
$value = (method_exists($item, $method))
? call_user_func([$item, $method])
: $item->get($sort);
<?php $collection = $this;
foreach ($actions as $method => $arguments) {
if (! method_exists($this, $method)) {
throw new MethodNotFoundException("The `$method` method doesn't exist.");
}
<?php if (! $data = $item->get($key)) {
$method = 'get'.ucfirst($key);
if (method_exists($item, $method)) {
$data = call_user_func([$item, $method]);
}
}
<?php protected function attemptAllRepositories($method, ...$args)
{
foreach ($this->repositories as $class) {
if (! method_exists($class, $method)) {
continue;
}
<?php public function augmentedArrayData()
{
return method_exists($this, 'values') ? $this->values() : $this->data();
}
}
<?php public function publish($options = [])
{
if (method_exists($this, 'revisionsEnabled') && $this->revisionsEnabled()) {
return $this->publishWorkingCopy($options);
}
<?php public function unpublish($options = [])
{
if (method_exists($this, 'revisionsEnabled') && $this->revisionsEnabled()) {
return $this->unpublishWorkingCopy($options);
}