master

laravel/framework

Last updated at: 29/12/2023 09:24

JobName.php

TLDR

This file contains the JobName class, which defines two static methods, parse() and resolve().

Methods

parse

This method parses a given job name into a class and method array. It takes a string parameter representing the job name and returns an array.

resolve

This method resolves the name of the queued job class. It takes two parameters: $name, which represents the name of the job, and $payload, which is an array of payload data. If the payload contains a non-empty displayName key, the method returns the value of that key. Otherwise, it returns the name parameter.

<?php

namespace Illuminate\Queue\Jobs;

use Illuminate\Support\Str;

class JobName
{
    /**
     * Parse the given job name into a class / method array.
     *
     * @param  string  $job
     * @return array
     */
    public static function parse($job)
    {
        return Str::parseCallback($job, 'fire');
    }

    /**
     * Get the resolved name of the queued job class.
     *
     * @param  string  $name
     * @param  array  $payload
     * @return string
     */
    public static function resolve($name, $payload)
    {
        if (! empty($payload['displayName'])) {
            return $payload['displayName'];
        }

        return $name;
    }
}