Beispiel #1
0
 /**
  * Get the private attributes
  *
  * @param string $key
  *
  * @return mixed
  */
 public function __get($key)
 {
     if (property_exists($this, $key)) {
         return $this->{$key};
     }
     if ($this->attributes->has($key)) {
         return $this->attributes->get($key);
     }
 }
 /** @test */
 public function should_sort_items_in_collection_and_reset_keys()
 {
     $this->collection->sort(function ($a, $b) {
         if ($a == $b) {
             return 0;
         }
         return $a < $b ? -1 : 1;
     });
     $this->collection->values();
     $this->assertEquals('Bart', $this->collection->get(0));
     $this->assertEquals('Homer', $this->collection->get(1));
     $this->assertEquals('Lisa', $this->collection->get(2));
     $this->assertEquals('Maggie', $this->collection->get(3));
     $this->assertEquals('Marge', $this->collection->get(4));
 }
Beispiel #3
0
 /**
  * Pick a product from the basket
  *
  * @param string $sku
  * @return Product
  */
 public function pick($sku)
 {
     return $this->products->get($sku);
 }