コード例 #1
0
ファイル: arr.php プロジェクト: SainsburysTests/sainsburys
 /**
  * Tests Arr::sum()
  *
  * @test
  */
 public function test_sum_multi_array()
 {
     $arr_multi = array(array('name' => 'foo', 'scores' => array('sports' => 5, 'math' => 20)), array('name' => 'bar', 'scores' => array('sports' => 7, 'math' => 15)), array('name' => 'fuel', 'scores' => array('sports' => 8, 'math' => 5)), array('name' => 'php', 'scores' => array('math' => 10)));
     $expected = 50;
     $test = \Arr::sum($arr_multi, 'scores.math');
     $this->assertEquals($expected, $test);
     $expected = 20;
     $test = \Arr::sum($arr_multi, 'scores.sports');
     $this->assertEquals($expected, $test);
 }
コード例 #2
0
ファイル: order.php プロジェクト: EdgeCommerce/edgecommerce
 /**
  * Calculate order total price
  * We will return sum of all kind of different 
  * prices that affect total price
  * 
  * @return type
  */
 public function total_price()
 {
     $total_price[]['price'] = $this->shipping_price;
     $total_price[]['price'] = $this->total_price;
     return \Arr::sum($total_price, 'price') - $this->discount_amount;
 }