# AttributeBagInterface

interface AttributeBagInterface implements SessionBagInterface

Attributes store.

## Methods

`public` | `string` | `getName()` | Gets this bag's name. | from SessionBagInterface
`public` | `` | `initialize(array $array)` | Initializes the Bag. | from SessionBagInterface
`public` | `string` | `getStorageKey()` | Gets the storage key for this bag. | from SessionBagInterface
`public` | `mixed` | `clear()` | Clears out data from bag. | from SessionBagInterface
`public` | `bool` | `has(string $name)` | Checks if an attribute is defined. |
`public` | `mixed` | `get(string $name, mixed $default = null)` | Returns an attribute. |
`public` | `` | `set(string $name, mixed $value)` | Sets an attribute. |
`public` | `array` | `all()` | Returns attributes. |
`public` | `` | `replace(array $attributes)` | Sets attributes. |
`public` | `mixed` | `remove(string $name)` | Removes an attribute. |

## Details

in SessionBagInterface at line 26

### `getName()`

`public string getName()`

Gets this bag's name.

#### Return Value

`string` |

in SessionBagInterface at line 31

### `initialize()`

`public initialize(array $array)`

Initializes the Bag.

#### Parameters

`array` | `$array` |

in SessionBagInterface at line 38

### `getStorageKey()`

`public string getStorageKey()`

Gets the storage key for this bag.

#### Return Value

`string` |

in SessionBagInterface at line 45

### `clear()`

`public mixed clear()`

Clears out data from bag.

#### Return Value

`mixed` | Whatever data was contained

at line 30

### `has()`

`public bool has(string $name)`

Checks if an attribute is defined.

#### Parameters

`string` | `$name` | The attribute name

#### Return Value

`bool` | true if the attribute is defined, false otherwise

at line 40

### `get()`

`public mixed get(string $name, mixed $default = null)`

Returns an attribute.

#### Parameters

`string` | `$name` | The attribute name
`mixed` | `$default` | The default value if not found

#### Return Value

`mixed` |

at line 48

### `set()`

`public set(string $name, mixed $value)`

Sets an attribute.

#### Parameters

`string` | `$name` |
`mixed` | `$value` |

at line 55

### `all()`

`public array all()`

Returns attributes.

#### Return Value

`array` | Attributes

at line 62

### `replace()`

`public replace(array $attributes)`

Sets attributes.

#### Parameters

`array` | `$attributes` | Attributes

at line 71

### `remove()`

`public mixed remove(string $name)`

Removes an attribute.

#### Parameters

`string` | `$name` |

#### Return Value

`mixed` | The removed value or null when it does not exist

## Source code

    <?php

    /*
     * This file is part of the Symfony package.
     *
     * (c) Fabien Potencier <fabien@symfony.com>
     *
     * For the full copyright and license information, please view the LICENSE
     * file that was distributed with this source code.
     */

    namespace Symfony\Component\HttpFoundation\Session\Attribute;

    use Symfony\Component\HttpFoundation\Session\SessionBagInterface;

    /**
     * Attributes store.
     *
     * @author Drak <drak@zikula.org>
     */
    interface AttributeBagInterface extends SessionBagInterface
    {
        /**
         * Checks if an attribute is defined.
         *
         * @param string $name The attribute name
         *
         * @return bool true if the attribute is defined, false otherwise
         */
        public function has($name);

        /**
         * Returns an attribute.
         *
         * @param string $name    The attribute name
         * @param mixed  $default The default value if not found
         *
         * @return mixed
         */
        public function get($name, $default = null);

        /**
         * Sets an attribute.
         *
         * @param string $name
         * @param mixed  $value
         */
        public function set($name, $value);

        /**
         * Returns attributes.
         *
         * @return array Attributes
         */
        public function all();

        /**
         * Sets attributes.
         *
         * @param array $attributes Attributes
         */
        public function replace(array $attributes);

        /**
         * Removes an attribute.
         *
         * @param string $name
         *
         * @return mixed The removed value or null when it does not exist
         */
        public function remove($name);
    }