Overview

Namespaces

  • Composer
    • Autoload
  • Illuminate
    • Support
      • Contracts
      • Facades
  • Laravella
    • Cart
      • Facades
  • None
  • PHP

Classes

  • ClassLoader
  • Collection
  • Fluent
  • Manager
  • MessageBag
  • NamespacedItemResolver
  • Pluralizer
  • SerializableClosure
  • ServiceProvider
  • Str
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php namespace Illuminate\Support;
  2: 
  3: use Closure;
  4: use ArrayAccess;
  5: 
  6: class Fluent implements ArrayAccess {
  7: 
  8:     /**
  9:      * All of the attributes set on the container.
 10:      *
 11:      * @var array
 12:      */
 13:     protected $attributes = array();
 14: 
 15:     /**
 16:      * Create a new fluent container instance.
 17:      *
 18:      * @param  array  $attributes
 19:      * @return void
 20:      */
 21:     public function __construct($attributes = array())
 22:     {
 23:         foreach ($attributes as $key => $value)
 24:         {
 25:             $this->attributes[$key] = $value;
 26:         }
 27:     }
 28: 
 29:     /**
 30:      * Get an attribute from the container.
 31:      *
 32:      * @param  string  $key
 33:      * @param  mixed   $default
 34:      * @return mixed
 35:      */
 36:     public function get($key, $default = null)
 37:     {
 38:         if (array_key_exists($key, $this->attributes))
 39:         {
 40:             return $this->attributes[$key];
 41:         }
 42: 
 43:         return value($default);
 44:     }
 45: 
 46:     /**
 47:      * Get the attributes from the container.
 48:      *
 49:      * @return array
 50:      */
 51:     public function getAttributes()
 52:     {
 53:         return $this->attributes;
 54:     }
 55: 
 56:     /**
 57:      * Determine if the given offset exists.
 58:      *
 59:      * @param  string  $offset
 60:      * @return bool
 61:      */
 62:     public function offsetExists($offset)
 63:     {
 64:         return isset($this->{$offset});
 65:     }
 66: 
 67:     /**
 68:      * Get the value for a given offset.
 69:      *
 70:      * @param  string  $offset
 71:      * @return mixed
 72:      */
 73:     public function offsetGet($offset)
 74:     {
 75:         return $this->{$offset};
 76:     }
 77: 
 78:     /**
 79:      * Set the value at the given offset.
 80:      *
 81:      * @param  string  $offset
 82:      * @param  mixed   $value
 83:      * @return void
 84:      */
 85:     public function offsetSet($offset, $value)
 86:     {
 87:         $this->{$offset} = $value;
 88:     }
 89: 
 90:     /**
 91:      * Unset the value at the given offset.
 92:      *
 93:      * @param  string  $offset
 94:      * @return void
 95:      */
 96:     public function offsetUnset($offset)
 97:     {
 98:         unset($this->{$offset});
 99:     }
100: 
101:     /**
102:      * Handle dynamic calls to the container to set attributes.
103:      *
104:      * @param  string  $method
105:      * @param  array   $parameters
106:      * @return \Illuminate\Support\Fluent
107:      */
108:     public function __call($method, $parameters)
109:     {
110:         $this->attributes[$method] = count($parameters) > 0 ? $parameters[0] : true;
111: 
112:         return $this;
113:     }
114: 
115:     /**
116:      * Dynamically retrieve the value of an attribute.
117:      *
118:      * @param  string  $key
119:      * @return mixed
120:      */
121:     public function __get($key)
122:     {
123:         return $this->get($key);
124:     }
125: 
126:     /**
127:      * Dynamically set the value of an attribute.
128:      *
129:      * @param  string  $key
130:      * @param  mixed   $value
131:      * @return void
132:      */
133:     public function __set($key, $value)
134:     {
135:         $this->attributes[$key] = $value;
136:     }
137: 
138:     /**
139:      * Dynamically check if an attribute is set.
140:      *
141:      * @param  string  $key
142:      * @return void
143:      */
144:     public function __isset($key)
145:     {
146:         return isset($this->attributes[$key]);
147:     }
148: 
149:     /**
150:      * Dynamically unset an attribute.
151:      *
152:      * @param  string  $key
153:      * @return void
154:      */
155:     public function __unset($key)
156:     {
157:         unset($this->attributes[$key]);
158:     }
159: 
160: }
cart API documentation generated by ApiGen 2.8.0