code
stringlengths 17
247k
| docstring
stringlengths 30
30.3k
| func_name
stringlengths 1
89
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
153
| url
stringlengths 51
209
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
protected function createDatabaseDriver()
{
return $this->container->make(Channels\DatabaseChannel::class);
} | Create an instance of the database driver.
@return \Illuminate\Notifications\Channels\DatabaseChannel | createDatabaseDriver | php | laravel/framework | src/Illuminate/Notifications/ChannelManager.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/ChannelManager.php | MIT |
protected function createBroadcastDriver()
{
return $this->container->make(Channels\BroadcastChannel::class);
} | Create an instance of the broadcast driver.
@return \Illuminate\Notifications\Channels\BroadcastChannel | createBroadcastDriver | php | laravel/framework | src/Illuminate/Notifications/ChannelManager.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/ChannelManager.php | MIT |
protected function createMailDriver()
{
return $this->container->make(Channels\MailChannel::class);
} | Create an instance of the mail driver.
@return \Illuminate\Notifications\Channels\MailChannel | createMailDriver | php | laravel/framework | src/Illuminate/Notifications/ChannelManager.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/ChannelManager.php | MIT |
public function getDefaultDriver()
{
return $this->defaultChannel;
} | Get the default channel driver name.
@return string | getDefaultDriver | php | laravel/framework | src/Illuminate/Notifications/ChannelManager.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/ChannelManager.php | MIT |
public function deliverVia($channel)
{
$this->defaultChannel = $channel;
} | Set the default channel driver name.
@param string $channel
@return void | deliverVia | php | laravel/framework | src/Illuminate/Notifications/ChannelManager.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/ChannelManager.php | MIT |
public function failed($e)
{
if (method_exists($this->notification, 'failed')) {
$this->notification->failed($e);
}
} | Call the failed method on the notification instance.
@param \Throwable $e
@return void | failed | php | laravel/framework | src/Illuminate/Notifications/SendQueuedNotifications.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/SendQueuedNotifications.php | MIT |
public function backoff()
{
if (! method_exists($this->notification, 'backoff') && ! isset($this->notification->backoff)) {
return;
}
return $this->notification->backoff ?? $this->notification->backoff();
} | Get the number of seconds before a released notification will be available.
@return mixed | backoff | php | laravel/framework | src/Illuminate/Notifications/SendQueuedNotifications.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/SendQueuedNotifications.php | MIT |
public function route($channel, $route)
{
if ($channel === 'database') {
throw new InvalidArgumentException('The database channel does not support on-demand notifications.');
}
$this->routes[$channel] = $route;
return $this;
} | Add routing information to the target.
@param string $channel
@param mixed $route
@return $this
@throws \InvalidArgumentException | route | php | laravel/framework | src/Illuminate/Notifications/AnonymousNotifiable.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/AnonymousNotifiable.php | MIT |
public function notifyNow($notification)
{
app(Dispatcher::class)->sendNow($this, $notification);
} | Send the given notification immediately.
@param mixed $notification
@return void | notifyNow | php | laravel/framework | src/Illuminate/Notifications/AnonymousNotifiable.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/AnonymousNotifiable.php | MIT |
public function routeNotificationFor($driver)
{
return $this->routes[$driver] ?? null;
} | Get the notification routing information for the given driver.
@param string $driver
@return mixed | routeNotificationFor | php | laravel/framework | src/Illuminate/Notifications/AnonymousNotifiable.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/AnonymousNotifiable.php | MIT |
public function getKey()
{
//
} | Get the value of the notifiable's primary key.
@return mixed | getKey | php | laravel/framework | src/Illuminate/Notifications/AnonymousNotifiable.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/AnonymousNotifiable.php | MIT |
public function __construct($manager, $bus, $events, $locale = null)
{
$this->bus = $bus;
$this->events = $events;
$this->locale = $locale;
$this->manager = $manager;
$this->events->listen(NotificationFailed::class, fn () => $this->failedEventWasDispatched = true);
} | Create a new notification sender instance.
@param \Illuminate\Notifications\ChannelManager $manager
@param \Illuminate\Contracts\Bus\Dispatcher $bus
@param \Illuminate\Contracts\Events\Dispatcher $events
@param string|null $locale | __construct | php | laravel/framework | src/Illuminate/Notifications/NotificationSender.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/NotificationSender.php | MIT |
protected function sendToNotifiable($notifiable, $id, $notification, $channel)
{
if (! $notification->id) {
$notification->id = $id;
}
if (! $this->shouldSendNotification($notifiable, $notification, $channel)) {
return;
}
try {
$response = $this->manager->driver($channel)->send($notifiable, $notification);
} catch (Throwable $exception) {
if (! $this->failedEventWasDispatched) {
$this->events->dispatch(
new NotificationFailed($notifiable, $notification, $channel, ['exception' => $exception])
);
}
$this->failedEventWasDispatched = false;
throw $exception;
}
$this->events->dispatch(
new NotificationSent($notifiable, $notification, $channel, $response)
);
} | Send the given notification to the given notifiable via a channel.
@param mixed $notifiable
@param string $id
@param mixed $notification
@param string $channel
@return void | sendToNotifiable | php | laravel/framework | src/Illuminate/Notifications/NotificationSender.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/NotificationSender.php | MIT |
protected function shouldSendNotification($notifiable, $notification, $channel)
{
if (method_exists($notification, 'shouldSend') &&
$notification->shouldSend($notifiable, $channel) === false) {
return false;
}
return $this->events->until(
new NotificationSending($notifiable, $notification, $channel)
) !== false;
} | Determines if the notification can be sent.
@param mixed $notifiable
@param mixed $notification
@param string $channel
@return bool | shouldSendNotification | php | laravel/framework | src/Illuminate/Notifications/NotificationSender.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/NotificationSender.php | MIT |
protected function formatNotifiables($notifiables)
{
if (! $notifiables instanceof Collection && ! is_array($notifiables)) {
return $notifiables instanceof Model
? new EloquentCollection([$notifiables])
: [$notifiables];
}
return $notifiables;
} | Format the notifiables into a Collection / array if necessary.
@param mixed $notifiables
@return \Illuminate\Database\Eloquent\Collection|array | formatNotifiables | php | laravel/framework | src/Illuminate/Notifications/NotificationSender.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/NotificationSender.php | MIT |
public function __construct(array $data = [])
{
$this->data = $data;
} | Create a new database message.
@param array $data | __construct | php | laravel/framework | src/Illuminate/Notifications/Messages/DatabaseMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/DatabaseMessage.php | MIT |
protected function formatLine($line)
{
if ($line instanceof Htmlable) {
return $line;
}
if (is_array($line)) {
return implode(' ', array_map(trim(...), $line));
}
return trim(implode(' ', array_map(trim(...), preg_split('/\\r\\n|\\r|\\n/', $line ?? ''))));
} | Format the given line of text.
@param \Illuminate\Contracts\Support\Htmlable|string|array|null $line
@return \Illuminate\Contracts\Support\Htmlable|string | formatLine | php | laravel/framework | src/Illuminate/Notifications/Messages/SimpleMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/SimpleMessage.php | MIT |
public function view($view, array $data = [])
{
$this->view = $view;
$this->viewData = $data;
$this->markdown = null;
return $this;
} | Set the view for the mail message.
@param array|string $view
@param array $data
@return $this | view | php | laravel/framework | src/Illuminate/Notifications/Messages/MailMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/MailMessage.php | MIT |
public function text($textView, array $data = [])
{
return $this->view([
'html' => is_array($this->view) ? ($this->view['html'] ?? null) : $this->view,
'text' => $textView,
], $data);
} | Set the plain text view for the mail message.
@param string $textView
@param array $data
@return $this | text | php | laravel/framework | src/Illuminate/Notifications/Messages/MailMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/MailMessage.php | MIT |
public function markdown($view, array $data = [])
{
$this->markdown = $view;
$this->viewData = $data;
$this->view = null;
return $this;
} | Set the Markdown template for the notification.
@param string $view
@param array $data
@return $this | markdown | php | laravel/framework | src/Illuminate/Notifications/Messages/MailMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/MailMessage.php | MIT |
public function template($template)
{
$this->markdown = $template;
return $this;
} | Set the default markdown template.
@param string $template
@return $this | template | php | laravel/framework | src/Illuminate/Notifications/Messages/MailMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/MailMessage.php | MIT |
public function from($address, $name = null)
{
$this->from = [$address, $name];
return $this;
} | Set the from address for the mail message.
@param string $address
@param string|null $name
@return $this | from | php | laravel/framework | src/Illuminate/Notifications/Messages/MailMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/MailMessage.php | MIT |
public function replyTo($address, $name = null)
{
if ($this->arrayOfAddresses($address)) {
$this->replyTo = array_merge($this->replyTo, $this->parseAddresses($address));
} else {
$this->replyTo[] = [$address, $name];
}
return $this;
} | Set the "reply to" address of the message.
@param array|string $address
@param string|null $name
@return $this | replyTo | php | laravel/framework | src/Illuminate/Notifications/Messages/MailMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/MailMessage.php | MIT |
public function cc($address, $name = null)
{
if ($this->arrayOfAddresses($address)) {
$this->cc = array_merge($this->cc, $this->parseAddresses($address));
} else {
$this->cc[] = [$address, $name];
}
return $this;
} | Set the cc address for the mail message.
@param array|string $address
@param string|null $name
@return $this | cc | php | laravel/framework | src/Illuminate/Notifications/Messages/MailMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/MailMessage.php | MIT |
public function bcc($address, $name = null)
{
if ($this->arrayOfAddresses($address)) {
$this->bcc = array_merge($this->bcc, $this->parseAddresses($address));
} else {
$this->bcc[] = [$address, $name];
}
return $this;
} | Set the bcc address for the mail message.
@param array|string $address
@param string|null $name
@return $this | bcc | php | laravel/framework | src/Illuminate/Notifications/Messages/MailMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/MailMessage.php | MIT |
public function priority($level)
{
$this->priority = $level;
return $this;
} | Set the priority of this message.
The value is an integer where 1 is the highest priority and 5 is the lowest.
@param int $level
@return $this | priority | php | laravel/framework | src/Illuminate/Notifications/Messages/MailMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/MailMessage.php | MIT |
public function data()
{
return array_merge($this->toArray(), $this->viewData);
} | Get the data array for the mail message.
@return array | data | php | laravel/framework | src/Illuminate/Notifications/Messages/MailMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/MailMessage.php | MIT |
protected function parseAddresses($value)
{
return (new Collection($value))
->map(fn ($address, $name) => [$address, is_numeric($name) ? null : $name])
->values()
->all();
} | Parse the multi-address array into the necessary format.
@param array $value
@return array | parseAddresses | php | laravel/framework | src/Illuminate/Notifications/Messages/MailMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/MailMessage.php | MIT |
protected function arrayOfAddresses($address)
{
return is_iterable($address) || $address instanceof Arrayable;
} | Determine if the given "address" is actually an array of addresses.
@param mixed $address
@return bool | arrayOfAddresses | php | laravel/framework | src/Illuminate/Notifications/Messages/MailMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/MailMessage.php | MIT |
public function render()
{
if (isset($this->view)) {
return Container::getInstance()->make('mailer')->render(
$this->view, $this->data()
);
}
$markdown = Container::getInstance()->make(Markdown::class);
return $markdown->theme($this->theme ?: $markdown->getTheme())
->render($this->markdown, $this->data());
} | Render the mail notification message into an HTML string.
@return \Illuminate\Support\HtmlString | render | php | laravel/framework | src/Illuminate/Notifications/Messages/MailMessage.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Messages/MailMessage.php | MIT |
protected function channelName()
{
if (method_exists($this->notifiable, 'receivesBroadcastNotificationsOn')) {
return $this->notifiable->receivesBroadcastNotificationsOn($this->notification);
}
$class = str_replace('\\', '.', get_class($this->notifiable));
return $class.'.'.$this->notifiable->getKey();
} | Get the broadcast channel name for the event.
@return array|string | channelName | php | laravel/framework | src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php | MIT |
public function broadcastWith()
{
if (method_exists($this->notification, 'broadcastWith')) {
return $this->notification->broadcastWith();
}
return array_merge($this->data, [
'id' => $this->notification->id,
'type' => $this->broadcastType(),
]);
} | Get the data that should be sent with the broadcasted event.
@return array | broadcastWith | php | laravel/framework | src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php | MIT |
public function broadcastType()
{
return method_exists($this->notification, 'broadcastType')
? $this->notification->broadcastType()
: get_class($this->notification);
} | Get the type of the notification being broadcast.
@return string | broadcastType | php | laravel/framework | src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php | MIT |
public function broadcastAs()
{
return method_exists($this->notification, 'broadcastAs')
? $this->notification->broadcastAs()
: __CLASS__;
} | Get the event name of the notification being broadcast.
@return string | broadcastAs | php | laravel/framework | src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php | MIT |
public function __construct(MailFactory $mailer, Markdown $markdown)
{
$this->mailer = $mailer;
$this->markdown = $markdown;
} | Create a new mail channel instance.
@param \Illuminate\Contracts\Mail\Factory $mailer
@param \Illuminate\Mail\Markdown $markdown | __construct | php | laravel/framework | src/Illuminate/Notifications/Channels/MailChannel.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Channels/MailChannel.php | MIT |
protected function buildMarkdownHtml($message)
{
return fn ($data) => $this->markdownRenderer($message)->render(
$message->markdown, array_merge($data, $message->data()),
);
} | Build the HTML view for a Markdown message.
@param \Illuminate\Notifications\Messages\MailMessage $message
@return \Closure | buildMarkdownHtml | php | laravel/framework | src/Illuminate/Notifications/Channels/MailChannel.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Channels/MailChannel.php | MIT |
protected function buildMarkdownText($message)
{
return fn ($data) => $this->markdownRenderer($message)->renderText(
$message->markdown, array_merge($data, $message->data()),
);
} | Build the text view for a Markdown message.
@param \Illuminate\Notifications\Messages\MailMessage $message
@return \Closure | buildMarkdownText | php | laravel/framework | src/Illuminate/Notifications/Channels/MailChannel.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Channels/MailChannel.php | MIT |
protected function markdownRenderer($message)
{
$config = Container::getInstance()->get(ConfigRepository::class);
$theme = $message->theme ?? $config->get('mail.markdown.theme', 'default');
return $this->markdown->theme($theme);
} | Get the Markdown implementation.
@param \Illuminate\Notifications\Messages\MailMessage $message
@return \Illuminate\Mail\Markdown | markdownRenderer | php | laravel/framework | src/Illuminate/Notifications/Channels/MailChannel.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Channels/MailChannel.php | MIT |
protected function additionalMessageData($notification)
{
return [
'__laravel_notification_id' => $notification->id,
'__laravel_notification' => get_class($notification),
'__laravel_notification_queued' => in_array(
ShouldQueue::class,
class_implements($notification)
),
];
} | Get additional meta-data to pass along with the view data.
@param \Illuminate\Notifications\Notification $notification
@return array | additionalMessageData | php | laravel/framework | src/Illuminate/Notifications/Channels/MailChannel.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Channels/MailChannel.php | MIT |
protected function getRecipients($notifiable, $notification, $message)
{
if (is_string($recipients = $notifiable->routeNotificationFor('mail', $notification))) {
$recipients = [$recipients];
}
return (new Collection($recipients))
->mapWithKeys(function ($recipient, $email) {
return is_numeric($email)
? [$email => (is_string($recipient) ? $recipient : $recipient->email)]
: [$email => $recipient];
})
->all();
} | Get the recipients of the given message.
@param mixed $notifiable
@param \Illuminate\Notifications\Notification $notification
@param \Illuminate\Notifications\Messages\MailMessage $message
@return mixed | getRecipients | php | laravel/framework | src/Illuminate/Notifications/Channels/MailChannel.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Channels/MailChannel.php | MIT |
protected function buildPayload($notifiable, Notification $notification)
{
return [
'id' => $notification->id,
'type' => method_exists($notification, 'databaseType')
? $notification->databaseType($notifiable)
: get_class($notification),
'data' => $this->getData($notifiable, $notification),
'read_at' => method_exists($notification, 'initialDatabaseReadAtValue')
? $notification->initialDatabaseReadAtValue($notifiable)
: null,
];
} | Build an array payload for the DatabaseNotification Model.
@param mixed $notifiable
@param \Illuminate\Notifications\Notification $notification
@return array | buildPayload | php | laravel/framework | src/Illuminate/Notifications/Channels/DatabaseChannel.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Channels/DatabaseChannel.php | MIT |
protected function getData($notifiable, Notification $notification)
{
if (method_exists($notification, 'toDatabase')) {
return is_array($data = $notification->toDatabase($notifiable))
? $data
: $data->data;
}
if (method_exists($notification, 'toArray')) {
return $notification->toArray($notifiable);
}
throw new RuntimeException('Notification is missing toDatabase / toArray method.');
} | Get the data for the notification.
@param mixed $notifiable
@param \Illuminate\Notifications\Notification $notification
@return array
@throws \RuntimeException | getData | php | laravel/framework | src/Illuminate/Notifications/Channels/DatabaseChannel.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Channels/DatabaseChannel.php | MIT |
protected function getData($notifiable, Notification $notification)
{
if (method_exists($notification, 'toBroadcast')) {
return $notification->toBroadcast($notifiable);
}
if (method_exists($notification, 'toArray')) {
return $notification->toArray($notifiable);
}
throw new RuntimeException('Notification is missing toBroadcast / toArray method.');
} | Get the data for the notification.
@param mixed $notifiable
@param \Illuminate\Notifications\Notification $notification
@return mixed
@throws \RuntimeException | getData | php | laravel/framework | src/Illuminate/Notifications/Channels/BroadcastChannel.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Notifications/Channels/BroadcastChannel.php | MIT |
public function __construct(string $command = '', int $exitCode = 0, array|string $output = '', array|string $errorOutput = '')
{
$this->command = $command;
$this->exitCode = $exitCode;
$this->output = $this->normalizeOutput($output);
$this->errorOutput = $this->normalizeOutput($errorOutput);
} | Create a new process result instance.
@param string $command
@param int $exitCode
@param array|string $output
@param array|string $errorOutput | __construct | php | laravel/framework | src/Illuminate/Process/FakeProcessResult.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/FakeProcessResult.php | MIT |
public function withCommand(string $command)
{
return new FakeProcessResult($command, $this->exitCode, $this->output, $this->errorOutput);
} | Create a new fake process result with the given command.
@param string $command
@return self | withCommand | php | laravel/framework | src/Illuminate/Process/FakeProcessResult.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/FakeProcessResult.php | MIT |
public function exitCode()
{
return $this->exitCode;
} | Get the exit code of the process.
@return int | exitCode | php | laravel/framework | src/Illuminate/Process/FakeProcessResult.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/FakeProcessResult.php | MIT |
public function successful()
{
return $this->collect()->every(fn ($p) => $p->successful());
} | Determine if all of the processes in the pool were successful.
@return bool | successful | php | laravel/framework | src/Illuminate/Process/ProcessPoolResults.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/ProcessPoolResults.php | MIT |
public function __construct(Factory $factory, callable $callback)
{
$this->factory = $factory;
$this->callback = $callback;
} | Create a new series of piped processes.
@param \Illuminate\Process\Factory $factory
@param callable $callback | __construct | php | laravel/framework | src/Illuminate/Process/Pipe.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Pipe.php | MIT |
public function stop(float $timeout = 10, ?int $signal = null)
{
return $this->process->stop($timeout, $signal);
} | Stop the process if it is still running.
@param float $timeout
@param int|null $signal
@return int|null | stop | php | laravel/framework | src/Illuminate/Process/InvokedProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/InvokedProcess.php | MIT |
public function ensureNotTimedOut()
{
try {
$this->process->checkTimeout();
} catch (SymfonyTimeoutException $e) {
throw new ProcessTimedOutException($e, new ProcessResult($this->process));
}
} | Ensure that the process has not timed out.
@return void
@throws \Illuminate\Process\Exceptions\ProcessTimedOutException | ensureNotTimedOut | php | laravel/framework | src/Illuminate/Process/InvokedProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/InvokedProcess.php | MIT |
public function wait(?callable $output = null)
{
try {
$this->process->wait($output);
return new ProcessResult($this->process);
} catch (SymfonyTimeoutException $e) {
throw new ProcessTimedOutException($e, new ProcessResult($this->process));
}
} | Wait for the process to finish.
@param callable|null $output
@return \Illuminate\Process\ProcessResult
@throws \Illuminate\Process\Exceptions\ProcessTimedOutException | wait | php | laravel/framework | src/Illuminate/Process/InvokedProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/InvokedProcess.php | MIT |
public function waitUntil(?callable $output = null)
{
try {
$this->process->waitUntil($output);
return new ProcessResult($this->process);
} catch (SymfonyTimeoutException $e) {
throw new ProcessTimedOutException($e, new ProcessResult($this->process));
}
} | Wait until the given callback returns true.
@param callable|null $output
@return \Illuminate\Process\ProcessResult
@throws \Illuminate\Process\Exceptions\ProcessTimedOutException | waitUntil | php | laravel/framework | src/Illuminate/Process/InvokedProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/InvokedProcess.php | MIT |
public function __construct(array $invokedProcesses)
{
$this->invokedProcesses = $invokedProcesses;
} | Create a new invoked process pool.
@param array $invokedProcesses | __construct | php | laravel/framework | src/Illuminate/Process/InvokedProcessPool.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/InvokedProcessPool.php | MIT |
public function signal(int $signal)
{
return $this->running()->each->signal($signal);
} | Send a signal to each running process in the pool, returning the processes that were signalled.
@param int $signal
@return \Illuminate\Support\Collection | signal | php | laravel/framework | src/Illuminate/Process/InvokedProcessPool.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/InvokedProcessPool.php | MIT |
public function stop(float $timeout = 10, ?int $signal = null)
{
return $this->running()->each->stop($timeout, $signal);
} | Stop all processes that are still running.
@param float $timeout
@param int|null $signal
@return \Illuminate\Support\Collection | stop | php | laravel/framework | src/Illuminate/Process/InvokedProcessPool.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/InvokedProcessPool.php | MIT |
public function running()
{
return (new Collection($this->invokedProcesses))->filter->running()->values();
} | Get the processes in the pool that are still currently running.
@return \Illuminate\Support\Collection | running | php | laravel/framework | src/Illuminate/Process/InvokedProcessPool.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/InvokedProcessPool.php | MIT |
public function wait()
{
return new ProcessPoolResults((new Collection($this->invokedProcesses))->map->wait()->all());
} | Wait for the processes to finish.
@return \Illuminate\Process\ProcessPoolResults | wait | php | laravel/framework | src/Illuminate/Process/InvokedProcessPool.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/InvokedProcessPool.php | MIT |
public function command(array|string $command)
{
$this->command = $command;
return $this;
} | Specify the command that will invoke the process.
@param array<array-key, string>|string $command
@return $this | command | php | laravel/framework | src/Illuminate/Process/PendingProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/PendingProcess.php | MIT |
public function path(string $path)
{
$this->path = $path;
return $this;
} | Specify the working directory of the process.
@param string $path
@return $this | path | php | laravel/framework | src/Illuminate/Process/PendingProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/PendingProcess.php | MIT |
public function timeout(int $timeout)
{
$this->timeout = $timeout;
return $this;
} | Specify the maximum number of seconds the process may run.
@param int $timeout
@return $this | timeout | php | laravel/framework | src/Illuminate/Process/PendingProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/PendingProcess.php | MIT |
public function idleTimeout(int $timeout)
{
$this->idleTimeout = $timeout;
return $this;
} | Specify the maximum number of seconds a process may go without returning output.
@param int $timeout
@return $this | idleTimeout | php | laravel/framework | src/Illuminate/Process/PendingProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/PendingProcess.php | MIT |
public function forever()
{
$this->timeout = null;
return $this;
} | Indicate that the process may run forever without timing out.
@return $this | forever | php | laravel/framework | src/Illuminate/Process/PendingProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/PendingProcess.php | MIT |
public function env(array $environment)
{
$this->environment = $environment;
return $this;
} | Set the additional environment variables for the process.
@param array $environment
@return $this | env | php | laravel/framework | src/Illuminate/Process/PendingProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/PendingProcess.php | MIT |
public function input($input)
{
$this->input = $input;
return $this;
} | Set the standard input that should be provided when invoking the process.
@param \Traversable|resource|string|int|float|bool|null $input
@return $this | input | php | laravel/framework | src/Illuminate/Process/PendingProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/PendingProcess.php | MIT |
public function quietly()
{
$this->quietly = true;
return $this;
} | Disable output for the process.
@return $this | quietly | php | laravel/framework | src/Illuminate/Process/PendingProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/PendingProcess.php | MIT |
public function tty(bool $tty = true)
{
$this->tty = $tty;
return $this;
} | Enable TTY mode for the process.
@param bool $tty
@return $this | tty | php | laravel/framework | src/Illuminate/Process/PendingProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/PendingProcess.php | MIT |
protected function toSymfonyProcess(array|string|null $command)
{
$command = $command ?? $this->command;
$process = is_iterable($command)
? new Process($command, null, $this->environment)
: Process::fromShellCommandline((string) $command, null, $this->environment);
$process->setWorkingDirectory((string) ($this->path ?? getcwd()));
$process->setTimeout($this->timeout);
if ($this->idleTimeout) {
$process->setIdleTimeout($this->idleTimeout);
}
if ($this->input) {
$process->setInput($this->input);
}
if ($this->quietly) {
$process->disableOutput();
}
if ($this->tty) {
$process->setTty(true);
}
if (! empty($this->options)) {
$process->setOptions($this->options);
}
return $process;
} | Get a Symfony Process instance from the current pending command.
@param array<array-key, string>|string|null $command
@return \Symfony\Component\Process\Process | toSymfonyProcess | php | laravel/framework | src/Illuminate/Process/PendingProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/PendingProcess.php | MIT |
public function supportsTty()
{
return Process::isTtySupported();
} | Determine whether TTY is supported on the current operating system.
@return bool | supportsTty | php | laravel/framework | src/Illuminate/Process/PendingProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/PendingProcess.php | MIT |
public function withFakeHandlers(array $fakeHandlers)
{
$this->fakeHandlers = $fakeHandlers;
return $this;
} | Specify the fake process result handlers for the pending process.
@param array $fakeHandlers
@return $this | withFakeHandlers | php | laravel/framework | src/Illuminate/Process/PendingProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/PendingProcess.php | MIT |
protected function fakeFor(string $command)
{
return (new Collection($this->fakeHandlers))
->first(fn ($handler, $pattern) => $pattern === '*' || Str::is($pattern, $command));
} | Get the fake handler for the given command, if applicable.
@param string $command
@return \Closure|null | fakeFor | php | laravel/framework | src/Illuminate/Process/PendingProcess.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/PendingProcess.php | MIT |
public function result(array|string $output = '', array|string $errorOutput = '', int $exitCode = 0)
{
return new FakeProcessResult(
output: $output,
errorOutput: $errorOutput,
exitCode: $exitCode,
);
} | Create a new fake process response for testing purposes.
@param array|string $output
@param array|string $errorOutput
@param int $exitCode
@return \Illuminate\Process\FakeProcessResult | result | php | laravel/framework | src/Illuminate/Process/Factory.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Factory.php | MIT |
public function describe()
{
return new FakeProcessDescription;
} | Begin describing a fake process lifecycle.
@return \Illuminate\Process\FakeProcessDescription | describe | php | laravel/framework | src/Illuminate/Process/Factory.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Factory.php | MIT |
public function sequence(array $processes = [])
{
return new FakeProcessSequence($processes);
} | Begin describing a fake process sequence.
@param array $processes
@return \Illuminate\Process\FakeProcessSequence | sequence | php | laravel/framework | src/Illuminate/Process/Factory.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Factory.php | MIT |
public function isRecording()
{
return $this->recording;
} | Determine if the process factory has fake process handlers and is recording processes.
@return bool | isRecording | php | laravel/framework | src/Illuminate/Process/Factory.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Factory.php | MIT |
public function recordIfRecording(PendingProcess $process, ProcessResultContract $result)
{
if ($this->isRecording()) {
$this->record($process, $result);
}
return $this;
} | Record the given process if processes should be recorded.
@param \Illuminate\Process\PendingProcess $process
@param \Illuminate\Contracts\Process\ProcessResult $result
@return $this | recordIfRecording | php | laravel/framework | src/Illuminate/Process/Factory.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Factory.php | MIT |
public function preventStrayProcesses(bool $prevent = true)
{
$this->preventStrayProcesses = $prevent;
return $this;
} | Indicate that an exception should be thrown if any process is not faked.
@param bool $prevent
@return $this | preventStrayProcesses | php | laravel/framework | src/Illuminate/Process/Factory.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Factory.php | MIT |
public function preventingStrayProcesses()
{
return $this->preventStrayProcesses;
} | Determine if stray processes are being prevented.
@return bool | preventingStrayProcesses | php | laravel/framework | src/Illuminate/Process/Factory.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Factory.php | MIT |
public function assertDidntRun(Closure|string $callback)
{
return $this->assertNotRan($callback);
} | Assert that a process was not recorded matching a given truth test.
@param \Closure|string $callback
@return $this | assertDidntRun | php | laravel/framework | src/Illuminate/Process/Factory.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Factory.php | MIT |
public function assertNothingRan()
{
PHPUnit::assertEmpty(
$this->recorded,
'An unexpected process was invoked.'
);
return $this;
} | Assert that no processes were recorded.
@return $this | assertNothingRan | php | laravel/framework | src/Illuminate/Process/Factory.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Factory.php | MIT |
public function pool(callable $callback)
{
return new Pool($this, $callback);
} | Start defining a pool of processes.
@param callable $callback
@return \Illuminate\Process\Pool | pool | php | laravel/framework | src/Illuminate/Process/Factory.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Factory.php | MIT |
public function pipe(callable|array $callback, ?callable $output = null)
{
return is_array($callback)
? (new Pipe($this, fn ($pipe) => (new Collection($callback))->each(
fn ($command) => $pipe->command($command)
)))->run(output: $output)
: (new Pipe($this, $callback))->run(output: $output);
} | Start defining a series of piped processes.
@param callable|array $callback
@return \Illuminate\Contracts\Process\ProcessResult | pipe | php | laravel/framework | src/Illuminate/Process/Factory.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Factory.php | MIT |
public function concurrently(callable $callback, ?callable $output = null)
{
return (new Pool($this, $callback))->start($output)->wait();
} | Run a pool of processes and wait for them to finish executing.
@param callable $callback
@param callable|null $output
@return \Illuminate\Process\ProcessPoolResults | concurrently | php | laravel/framework | src/Illuminate/Process/Factory.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Factory.php | MIT |
public function newPendingProcess()
{
return (new PendingProcess($this))->withFakeHandlers($this->fakeHandlers);
} | Create a new pending process associated with this factory.
@return \Illuminate\Process\PendingProcess | newPendingProcess | php | laravel/framework | src/Illuminate/Process/Factory.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Factory.php | MIT |
public function __call($method, $parameters)
{
if (static::hasMacro($method)) {
return $this->macroCall($method, $parameters);
}
return $this->newPendingProcess()->{$method}(...$parameters);
} | Dynamically proxy methods to a new pending process instance.
@param string $method
@param array $parameters
@return mixed | __call | php | laravel/framework | src/Illuminate/Process/Factory.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Factory.php | MIT |
public function __construct(SymfonyTimeoutException $original, ProcessResult $result)
{
$this->result = $result;
parent::__construct($original->getMessage(), $original->getCode(), $original);
} | Create a new exception instance.
@param \Symfony\Component\Process\Exception\ProcessTimedOutException $original
@param \Illuminate\Contracts\Process\ProcessResult $result | __construct | php | laravel/framework | src/Illuminate/Process/Exceptions/ProcessTimedOutException.php | https://github.com/laravel/framework/blob/master/src/Illuminate/Process/Exceptions/ProcessTimedOutException.php | MIT |
protected function catchException($class, $executor)
{
try {
$executor();
} catch (Exception $e) {
if (is_a($e, $class)) {
return $e;
}
throw $e;
}
throw new Exception("No exception thrown. Expected exception {$class}.");
} | Catch the given exception thrown from the executor, and return it.
@param string $class
@param \Closure $executor
@return \Exception
@throws \Exception | catchException | php | laravel/framework | tests/Foundation/FoundationFormRequestTest.php | https://github.com/laravel/framework/blob/master/tests/Foundation/FoundationFormRequestTest.php | MIT |
protected function createRequest($payload = [], $class = FoundationTestFormRequestStub::class)
{
$container = tap(new Container, function ($container) {
$container->instance(
ValidationFactoryContract::class,
$this->createValidationFactory($container)
);
});
$request = $class::create('/', 'GET', $payload);
return $request->setRedirector($this->createMockRedirector($request))
->setContainer($container);
} | Create a new request of the given type.
@param array $payload
@param string $class
@return \Illuminate\Foundation\Http\FormRequest | createRequest | php | laravel/framework | tests/Foundation/FoundationFormRequestTest.php | https://github.com/laravel/framework/blob/master/tests/Foundation/FoundationFormRequestTest.php | MIT |
protected function createValidationFactory($container)
{
$translator = m::mock(Translator::class)->shouldReceive('get')
->zeroOrMoreTimes()->andReturn('error')->getMock();
return new ValidationFactory($translator, $container);
} | Create a new validation factory.
@param \Illuminate\Container\Container $container
@return \Illuminate\Validation\Factory | createValidationFactory | php | laravel/framework | tests/Foundation/FoundationFormRequestTest.php | https://github.com/laravel/framework/blob/master/tests/Foundation/FoundationFormRequestTest.php | MIT |
protected function createMockRedirectResponse()
{
return $this->mocks['redirect'] = m::mock(RedirectResponse::class);
} | Create a mock redirect response.
@return \Illuminate\Http\RedirectResponse | createMockRedirectResponse | php | laravel/framework | tests/Foundation/FoundationFormRequestTest.php | https://github.com/laravel/framework/blob/master/tests/Foundation/FoundationFormRequestTest.php | MIT |
protected function connection()
{
return Eloquent::getConnectionResolver()->connection();
} | Get a database connection instance.
@return \Illuminate\Database\Connection | connection | php | laravel/framework | tests/Queue/QueueDatabaseQueueIntegrationTest.php | https://github.com/laravel/framework/blob/master/tests/Queue/QueueDatabaseQueueIntegrationTest.php | MIT |
protected function resolveApplicationExceptionHandler($app)
{
$app->singleton('Illuminate\Contracts\Debug\ExceptionHandler', 'Illuminate\Foundation\Exceptions\Handler');
} | Resolve application HTTP exception handler.
@param \Illuminate\Foundation\Application $app
@return void | resolveApplicationExceptionHandler | php | laravel/framework | tests/Integration/Foundation/ExceptionHandlerTest.php | https://github.com/laravel/framework/blob/master/tests/Integration/Foundation/ExceptionHandlerTest.php | MIT |
protected function resolveApplication()
{
return Application::configure(static::applicationBasePath())
->withRouting(
web: __DIR__.'/fixtures/web.php',
health: '/up',
)->create();
} | Resolve application implementation.
@return \Illuminate\Foundation\Application | resolveApplication | php | laravel/framework | tests/Integration/Foundation/Support/Providers/RouteServiceProviderHealthTest.php | https://github.com/laravel/framework/blob/master/tests/Integration/Foundation/Support/Providers/RouteServiceProviderHealthTest.php | MIT |
protected function ignoringMockOnceExceptions(callable $callback)
{
try {
$callback();
} finally {
try {
m::close();
} catch (InvalidCountException) {
// Ignore mock exception from PendingCommand::expectsOutput().
}
}
} | Don't allow Mockery's InvalidCountException to be reported. Mocks setup
in PendingCommand cause PHPUnit tearDown() to later throw the exception.
@param callable $callback
@return void | ignoringMockOnceExceptions | php | laravel/framework | tests/Integration/Testing/ArtisanCommandTest.php | https://github.com/laravel/framework/blob/master/tests/Integration/Testing/ArtisanCommandTest.php | MIT |
public function dynamoTableExists(DynamoDbClient $client, $table)
{
try {
$client->describeTable([
'TableName' => $table,
]);
return true;
} catch (AwsException $e) {
if (Str::contains($e->getAwsErrorMessage(), ['resource not found', 'Cannot do operations on a non-existent table'])) {
return false;
}
throw $e;
}
} | Determine if the given DynamoDB table exists.
@param \Aws\DynamoDb\DynamoDbClient $client
@param string $table
@return bool | dynamoTableExists | php | laravel/framework | tests/Integration/Cache/DynamoDbStoreTest.php | https://github.com/laravel/framework/blob/master/tests/Integration/Cache/DynamoDbStoreTest.php | MIT |
protected function fallbackRoute($action)
{
$placeholder = 'fallbackPlaceholder';
return $this->newRoute(
'GET', "{{$placeholder}}", $action
)->where($placeholder, '.*')->fallback();
} | Create a new fallback Route object.
@param mixed $action
@return \Illuminate\Routing\Route | fallbackRoute | php | laravel/framework | tests/Integration/Routing/CompiledRouteCollectionTest.php | https://github.com/laravel/framework/blob/master/tests/Integration/Routing/CompiledRouteCollectionTest.php | MIT |
protected function createProxiedRequest($serverOverrides = [])
{
// Add some X-Forwarded headers and over-ride
// defaults, simulating a request made over a proxy
$serverOverrides = array_replace([
'HTTP_X_FORWARDED_FOR' => '173.174.200.38', // X-Forwarded-For -- getClientIp()
'HTTP_X_FORWARDED_HOST' => 'serversforhackers.com', // X-Forwarded-Host -- getHosts()
'HTTP_X_FORWARDED_PORT' => '443', // X-Forwarded-Port -- getPort()
'HTTP_X_FORWARDED_PREFIX' => '/prefix', // X-Forwarded-Prefix -- getBaseUrl()
'HTTP_X_FORWARDED_PROTO' => 'https', // X-Forwarded-Proto -- getScheme() / isSecure()
'SERVER_PORT' => 8888,
'HTTP_HOST' => 'localhost',
'REMOTE_ADDR' => '192.168.10.10',
], $serverOverrides);
// Create a fake request made over "http", one that we'd get over a proxy
// which is likely something like this:
$request = Request::create('http://localhost:8888/tag/proxy', 'GET', [], [], [], $serverOverrides, null);
// Need to make sure these haven't already been set
$request->setTrustedProxies([], $this->headerAll);
return $request;
} | Fake an HTTP request by generating a Symfony Request object.
@param array $serverOverrides
@return \Illuminate\Http\Request | createProxiedRequest | php | laravel/framework | tests/Http/Middleware/TrustProxiesTest.php | https://github.com/laravel/framework/blob/master/tests/Http/Middleware/TrustProxiesTest.php | MIT |
protected function createTrustedProxy($trustedHeaders, $trustedProxies)
{
return new class($trustedHeaders, $trustedProxies) extends TrustProxies
{
public function __construct($trustedHeaders, $trustedProxies)
{
$this->headers = $trustedHeaders;
$this->proxies = $trustedProxies;
}
};
} | Create an anonymous middleware class.
@param null|string|int $trustedHeaders
@param null|array|string $trustedProxies
@return \Illuminate\Http\Middleware\TrustProxies | createTrustedProxy | php | laravel/framework | tests/Http/Middleware/TrustProxiesTest.php | https://github.com/laravel/framework/blob/master/tests/Http/Middleware/TrustProxiesTest.php | MIT |
protected function getRoute()
{
return last($this->router->getRoutes()->get());
} | Get the last route registered with the router.
@return \Illuminate\Routing\Route | getRoute | php | laravel/framework | tests/Routing/RouteRegistrarTest.php | https://github.com/laravel/framework/blob/master/tests/Routing/RouteRegistrarTest.php | MIT |
protected function seeMiddleware($middleware)
{
$this->assertEquals($middleware, $this->getRoute()->middleware()[0]);
} | Assert that the last route has the given middleware.
@param string $middleware
@return void | seeMiddleware | php | laravel/framework | tests/Routing/RouteRegistrarTest.php | https://github.com/laravel/framework/blob/master/tests/Routing/RouteRegistrarTest.php | MIT |
protected function seeResponse($content, Request $request)
{
$route = $this->getRoute();
$this->assertTrue($route->matches($request));
$this->assertEquals($content, $route->bind($request)->run());
} | Assert that the last route has the given content.
@param string $content
@param \Illuminate\Http\Request $request
@return void | seeResponse | php | laravel/framework | tests/Routing/RouteRegistrarTest.php | https://github.com/laravel/framework/blob/master/tests/Routing/RouteRegistrarTest.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.