Ejemplo n.º 1
0
 /**
  * Defines a point where hooks can hook
  *
  * @param string $event The hook name
  * @param array  $args  (optional) The arguments to pass along
  * @param bool   $halt  (optional) If this hook can halt
  *
  * @return array|null
  */
 protected function hookPoint($event, array $args = [], $halt = true)
 {
     if (config('codex.dev.enabled', false) === true) {
         if (array_key_exists($event, static::$hookPoints)) {
             throw CodexException::because('hook point already exists');
         }
         Arr::add(static::$hooks, $event, static::getDispatcher()->getListeners($event));
         $caller = $this->hookPointGetCaller(debug_backtrace(), 1);
         $caller = array_only($caller, ['function', 'class']);
         Arr::set(static::$hookPoints, static::getEventName($event), $caller);
     }
     return $this->fireEvent($event, $args, $halt);
 }
Ejemplo n.º 2
0
 public function has($key)
 {
     return Arr::has($this->items, $key);
 }
Ejemplo n.º 3
0
 public function forget($keys)
 {
     Arr::forget($this->items, $keys);
     return $this;
 }
Ejemplo n.º 4
0
 public function testRemoveValue()
 {
     // numeric array
     $a = ['foo', 'bar', 'baz'];
     $this->assertCount(2, Arr::removeValue($a, 'bar'));
     $this->assertNotContains('bar', Arr::removeValue($a, 'bar'));
     $this->assertContains('foo', Arr::removeValue($a, 'bar'));
     $this->assertContains('baz', Arr::removeValue($a, 'bar'));
     // associative array
     $a = ['foo' => 'bar', 'faz' => 'ter', 'one' => 'two'];
     $this->assertCount(2, Arr::removeValue($a, 'bar'));
     $this->assertNotContains('bar', array_values(Arr::removeValue($a, 'bar')));
     $this->assertContains('ter', array_values(Arr::removeValue($a, 'bar')));
     $this->assertContains('two', array_values(Arr::removeValue($a, 'bar')));
 }
Ejemplo n.º 5
0
 public function get($name, $default = null)
 {
     return Arr::get($this->items, $name, $default);
 }