Debian Codegraph @

lib/3rdParty/composer/illuminate/support/DefaultProviders.php

raw symbols SCIP
1 <?php
2
3 namespace Illuminate\Support;
4
5 class DefaultProviders
6 {
7 /**
8 * The current providers.
9 *
10 * @var array
11 */
12 protected $providers;
13
14 /**
15 * Create a new default provider collection.
16 */
17 public function __construct(?array $providers = null)
18 {
19 $this->providers = $providers ?: [
20 \Illuminate\Auth\AuthServiceProvider::class,
21 \Illuminate\Broadcasting\BroadcastServiceProvider::class,
22 \Illuminate\Bus\BusServiceProvider::class,
23 \Illuminate\Cache\CacheServiceProvider::class,
24 \Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
25 \Illuminate\Concurrency\ConcurrencyServiceProvider::class,
26 \Illuminate\Cookie\CookieServiceProvider::class,
27 \Illuminate\Database\DatabaseServiceProvider::class,
28 \Illuminate\Encryption\EncryptionServiceProvider::class,
29 \Illuminate\Filesystem\FilesystemServiceProvider::class,
30 \Illuminate\Foundation\Providers\FoundationServiceProvider::class,
31 \Illuminate\Hashing\HashServiceProvider::class,
32 \Illuminate\Mail\MailServiceProvider::class,
33 \Illuminate\Notifications\NotificationServiceProvider::class,
34 \Illuminate\Pagination\PaginationServiceProvider::class,
35 \Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
36 \Illuminate\Pipeline\PipelineServiceProvider::class,
37 \Illuminate\Queue\QueueServiceProvider::class,
38 \Illuminate\Redis\RedisServiceProvider::class,
39 \Illuminate\Session\SessionServiceProvider::class,
40 \Illuminate\Translation\TranslationServiceProvider::class,
41 \Illuminate\Validation\ValidationServiceProvider::class,
42 \Illuminate\View\ViewServiceProvider::class,
43 ];
44 }
45
46 /**
47 * Merge the given providers into the provider collection.
48 *
49 * @param array $providers
50 * @return static
51 */
52 public function merge(array $providers)
53 {
54 $this->providers = array_merge($this->providers, $providers);
55
56 return new static($this->providers);
57 }
58
59 /**
60 * Replace the given providers with other providers.
61 *
62 * @param array $replacements
63 * @return static
64 */
65 public function replace(array $replacements)
66 {
67 $current = new Collection($this->providers);
68
69 foreach ($replacements as $from => $to) {
70 $key = $current->search($from);
71
72 $current = is_int($key) ? $current->replace([$key => $to]) : $current;
73 }
74
75 return new static($current->values()->toArray());
76 }
77
78 /**
79 * Disable the given providers.
80 *
81 * @param array $providers
82 * @return static
83 */
84 public function except(array $providers)
85 {
86 return new static((new Collection($this->providers))
87 ->reject(fn ($p) => in_array($p, $providers))
88 ->values()
89 ->toArray());
90 }
91
92 /**
93 * Convert the provider collection to an array.
94 *
95 * @return array
96 */
97 public function toArray()
98 {
99 return $this->providers;
100 }
101 }