master

laravel/framework

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

PublishingStubs.php

TLDR

This file defines a class called PublishingStubs that represents an event in the Illuminate Foundation Events package. The class has a property $stubs that holds an array of stubs to be published. The class also has a constructor and a method add to add new stubs to the array.

Classes

PublishingStubs

The PublishingStubs class represents an event in the Illuminate Foundation Events package. It has the following features:

  • The class extends the Dispatchable trait.
  • The class has a public property $stubs that holds an array of stubs to be published.
  • The class has a constructor __construct which accepts an array of stubs and assigns it to the $stubs property.
  • The class has a method add that takes a path and a name and adds a new stub to the $stubs array.
<?php

namespace Illuminate\Foundation\Events;

class PublishingStubs
{
    use Dispatchable;

    /**
     * The stubs being published.
     *
     * @var array
     */
    public $stubs = [];

    /**
     * Create a new event instance.
     *
     * @param  array  $stubs
     * @return void
     */
    public function __construct(array $stubs)
    {
        $this->stubs = $stubs;
    }

    /**
     * Add a new stub to be published.
     *
     * @param  string  $path
     * @param  string  $name
     * @return $this
     */
    public function add(string $path, string $name)
    {
        $this->stubs[$path] = $name;

        return $this;
    }
}