make() public static method

Get a new dictionary with the given attributes.
public static make ( mixed $attributes ) : Dictionary
$attributes mixed
return Dictionary
Exemplo n.º 1
0
 public function test_allows_checking_attributes()
 {
     $data = ['lime' => 'tree', 'cherry'];
     $dict = Dictionary::make($data);
     $this->assertTrue(isset($dict->lime));
     $this->assertFalse(isset($dict->nooooppeee));
     $this->assertTrue(empty($dict->nogood));
     $this->assertFalse(empty($dict->lime));
     $this->assertNull($dict->nogood);
     $this->assertNull($dict->cherry);
 }
Exemplo n.º 2
0
 /**
  * Wrap the given callback with a proxy Closure.
  * The reason we use this is to be able to format the given $data into a Dictionary
  * which makes it safer to work with them.
  *
  * @param  mixed $callback
  * @param  boolean $isFunction
  *
  * @return Closure
  */
 public function wrapWithProxy($callback, $isFunction = false)
 {
     // We will wrap the callback with a Closure so that we can format the kwArgs that we receive
     // into our proprietary Dictionary instance to make things safer.
     return function ($args, $kwArgs) use($callback, $isFunction) {
         if (is_string($callback) && !$isFunction && $this->getDelegateProvider() instanceof Provider) {
             $callback = [$this->getDelegateProvider(), $callback];
         }
         return call_user_func_array($callback, [$args, Dictionary::make($kwArgs)]);
     };
 }
Exemplo n.º 3
0
 /**
  * Get a new Content instance from an instance of \Agency\Content.
  *
  * @param  \Agency\Content $content
  *
  * @return \Agency\RealTime\Content
  */
 public static function makeFromContent(PublishedContent $content)
 {
     return new static(Dictionary::make(['content' => ['id' => $content->getKey(), 'type' => self::TYPE_ANY]]));
 }