master

laravel/framework

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

Repository.php

TLDR

This file is an interface for the Repository class in the Illuminate\Contracts\Config namespace. It defines several methods for working with configuration values.

Methods

has

This method is used to check if a given configuration value exists.

  • Parameters:
    • $key: The configuration key to check
  • Returns:
    • bool: true if the configuration value exists, false otherwise

get

This method is used to retrieve a specified configuration value.

  • Parameters:
    • $key: The configuration key to retrieve. It can be an array or a string.
    • $default (optional): The default value to return if the configuration value is not found.
  • Returns:
    • mixed: The retrieved configuration value, or the default value if the configuration value is not found.

all

This method is used to retrieve all of the configuration items for the application.

  • Returns:
    • array: An array containing all of the configuration items.

set

This method is used to set a given configuration value.

  • Parameters:
    • $key: The configuration key to set. It can be an array or a string.
    • $value: The value to set for the configuration key.
  • Returns:
    • void

prepend

This method is used to prepend a value onto an array configuration value.

  • Parameters:
    • $key: The configuration key of the array.
    • $value: The value to prepend.
  • Returns:
    • void

push

This method is used to push a value onto an array configuration value.

  • Parameters:
    • $key: The configuration key of the array.
    • $value: The value to push.
  • Returns:
    • void
<?php

namespace Illuminate\Contracts\Config;

interface Repository
{
    /**
     * Determine if the given configuration value exists.
     *
     * @param  string  $key
     * @return bool
     */
    public function has($key);

    /**
     * Get the specified configuration value.
     *
     * @param  array|string  $key
     * @param  mixed  $default
     * @return mixed
     */
    public function get($key, $default = null);

    /**
     * Get all of the configuration items for the application.
     *
     * @return array
     */
    public function all();

    /**
     * Set a given configuration value.
     *
     * @param  array|string  $key
     * @param  mixed  $value
     * @return void
     */
    public function set($key, $value = null);

    /**
     * Prepend a value onto an array configuration value.
     *
     * @param  string  $key
     * @param  mixed  $value
     * @return void
     */
    public function prepend($key, $value);

    /**
     * Push a value onto an array configuration value.
     *
     * @param  string  $key
     * @param  mixed  $value
     * @return void
     */
    public function push($key, $value);
}