コード例 #1
0
ファイル: cart_usage.php プロジェクト: ymnl007/designpatterns
<?php

require 'cart.php';
$cart = array(CarFactory::create('Bmw'), CarFactory::create('xyzwtf'));
foreach ($cart as $car) {
    $totalPrice += $car->getPrice();
}
echo "The total price for all the cars found in Cart is: {$totalPrice}";
コード例 #2
0
ファイル: cart_test.php プロジェクト: ymnl007/designpatterns
 public function testFactoryReturnsAnObject()
 {
     $car = CarFactory::create('carThatDoesNotExist');
     $this->assertEquals(0, $car->getPrice());
 }