コード例 #1
0
ファイル: Set.php プロジェクト: cubiche/cubiche
 /**
  * @param array|\Traversable $enumerable
  * @param callable           $equalityComparer
  *
  * @return \Cubiche\Core\Enumerable\EnumerableInterface
  */
 public function union($enumerable, callable $equalityComparer = null)
 {
     $iterator = new \AppendIterator();
     $iterator->append(Enumerable::from($this)->getIterator());
     $iterator->append(Enumerable::from($enumerable)->getIterator());
     return Enumerable::from($iterator)->distinct($equalityComparer);
 }
コード例 #2
0
 /**
  * @param array|\Traversable $enumerable
  */
 public function __construct($enumerable)
 {
     $this->enumerable = Enumerable::from($enumerable);
 }
コード例 #3
0
ファイル: Inventory.php プロジェクト: xander-mbaka/momentum
 public static function Create($name, $ref, $desc, $manufacturer, $features, $pprice, $rprice, $wprice, $tax, $img, $pheight, $pwidth, $plength, $pweight, $pshape, $images)
 {
     $unit = Enumerable::Create('Item');
     //temporal, individual,
     $typedata = ResourceType::FetchType("Good", $unit);
     $sqlone = 'SELECT * FROM products WHERE name = "' . $name . '" AND reference = "' . $ref . '"';
     $res = DatabaseHandler::GetRow($sqlone);
     if (empty($res)) {
         //create product
         $sql = 'INSERT INTO products (type_id, type_name, name, reference, description, retail_price, wholesale_price, tax_code, img_url, manufacturer) 
         VALUES (' . $typedata['id'] . ', "' . $typedata['type'] . '", "' . $name . '", "' . $ref . '", "' . $desc . '", "' . $rprice . '", "' . $wprice . '", "' . $tax . '", "' . $img . '", "' . $manufacturer . '")';
         DatabaseHandler::Execute($sql);
         $sqlone = 'SELECT resource_id FROM products WHERE name = "' . $name . '" AND reference = "' . $ref . '"';
         $res = DatabaseHandler::GetRow($sqlone);
         //create product features
         foreach ($features as $feature) {
             $sql = 'INSERT INTO features (resource_id, attribute) VALUES (' . $res['resource_id'] . ', "' . $feature . '")';
             DatabaseHandler::Execute($sql);
         }
         $sqltwo = 'SELECT * FROM features WHERE resource_id = ' . $res['resource_id'];
         $features = DatabaseHandler::GetAll($sqltwo);
         //create product images
         foreach ($images as $image) {
             foreach ($image['features'] as $feature) {
                 $sql = 'INSERT INTO images (resource_id, image_title, image_url, tag, value) VALUES (' . $res['resource_id'] . ', "' . $image['imgtitle'] . '", "' . $image['imgurl'] . '", "' . $feature['feature'] . '", "' . $feature['value'] . '")';
                 DatabaseHandler::Execute($sql);
             }
         }
         //$sqltwo = 'SELECT * FROM images WHERE resource_id = '.$res['resource_id'];
         //$images = ProductImage::FetchImages($res['resource_id']);
     }
     $product = new Product($res['resource_id'], $typedata['id'], $typedata['type'], $name, $ref, $unit, $desc, $features, $manufacturer, $rprice, $wprice, $tax, $img, $plength, $pwidth, $pheight, $pweight, $pshape);
     return $product;
     // $product->setShippingDetails($res['id'], $plength, $pwidth, $pheight, $pweight, $pshape);
     /*/after creation it returns the product object to be used in the inventory, shipping and category classes
       $couriers, $shippingmethod = [$road, $air, $sea, $space] //shipping class - dispatch and delivery
       $cat //category class
       $avail, $featured, $openstock, $optstock, $lowstock //inventory class
       $pprice // determined by supplier and varies with batch -- same product different batches and prices will lead to different valuation of stock
       */
 }
コード例 #4
0
ファイル: enumerable.php プロジェクト: speedmax/phuby
    {
        $result = $this->array;
        foreach ($result as $key => $value) {
            if ($value instanceof Enumerable) {
                $result[$key] = $value->to_native_a();
            }
        }
        return $result;
    }
    function values()
    {
        return array_values($this->array);
    }
    function values_at($keys)
    {
        $keys = func_get_args();
        $result = new Arr();
        foreach ($keys as $key) {
            $result[] = $this[$key];
        }
        return $result;
    }
}
Enumerable::extend('EnumerableMethods');
Enumerable::alias_method('at', 'offsetGet');
Enumerable::alias_method('fetch', 'offsetGet');
Enumerable::alias_method('length', 'count');
Enumerable::alias_method('map', 'collect');
Enumerable::alias_method('size', 'count');
Enumerable::alias_method('store', 'offsetSet');
コード例 #5
0
ファイル: Linq.php プロジェクト: fabricius/yalinqo
 public static function from($source)
 {
     return Enumerable::from($source);
 }
コード例 #6
0
ファイル: Partitioning.php プロジェクト: cubiche/cubiche
 /**
  * @param int $offset
  * @param int $length
  *
  * @return \Cubiche\Core\Enumerable\EnumerableInterface
  */
 public function slice($offset, $length = null)
 {
     return new SlicedEnumerable(Enumerable::from($this), $offset, $length);
 }