本文整理汇总了PHP中Car类的典型用法代码示例。如果您正苦于以下问题:PHP Car类的具体用法?PHP Car怎么用?PHP Car使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Car类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buyCar
public function buyCar(Car $car)
{
if ($this->getMoney() >= $car->getPrice()) {
$this->setMoney($this->getMoney() - $car->getPrice());
$this->setCar($car);
}
}
示例2: wordpress_setup
function wordpress_setup() {
$car = new Car();
add_action('init',function() use ($car){
register_taxonomy('car',array('fill'), $car->taxonomy());
});
add_action('template_include',function($template){
global $wp,$wp_query;
if($wp_query->query_vars['taxonomy']=='car'
&& isset($_SERVER['HTTP_X_REQUESTED_WITH'])
&& strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'
){
$new_template = locate_template( array( 'taxonomy-car_ajax.php' ) );
if ( '' != $new_template ) {
return $new_template ;
}
}
elseif ($wp->request == 'car') {
$new_template = locate_template( array( 'archive-car.php' ) );
if ( '' != $new_template ) {
return $new_template ;
}
}
return $template;
});
return $this;
}
示例3: testBridge
public function testBridge()
{
$expect = "SssuuuuZzzuuuuKkiiiii";
$car = new Car(new EngineSuzuki());
$sound = $car->rase();
$this->assertEquals($sound, $expect);
}
示例4: isStreetLegal
protected function isStreetLegal(Car $car)
{
if ($car->getMaximumSpeed() < $this->speedLimit) {
return true;
} else {
return false;
}
}
示例5: copy
public function copy()
{
$car = new Car();
$car->setBody($this->getBody());
$car->setWheel($this->getWheel());
$car->setEngine($this->getEngine());
return $car;
}
示例6: testCarPartsFactoryCreateEngineCalled
public function testCarPartsFactoryCreateEngineCalled()
{
$hybridEngine = new HybridEngine();
$factoryStub = $this->getMock('HybridCarPartsFactory');
$factoryStub->expects($this->once())->method('createEngine')->will($this->returnValue($hybridEngine));
$car = new Car($factoryStub);
$car->start();
}
示例7: testName
public function testName()
{
// Create new Car and pass in a name
$car = new Car("Murcielago");
// Get the car name
$result = $car->name();
// Assert that the name has been set correctly
$this->assertEquals("Murcielago", $result);
}
示例8: testMaxSpeed
public function testMaxSpeed()
{
$car = new Car();
for ($i = 0; $i < 10; $i++) {
$car->accelerate();
}
$this->assertEquals(100, $car->getSpeed());
$car->accelerate();
$this->assertEquals(100, $car->getSpeed());
}
示例9: withPriceandMaxspeed
public static function withPriceandMaxspeed($model, $isSportsCar, $color, $price, $maxSpeed)
{
$car = new Car();
$car->model = $model;
$car->isSportscar = $isSportsCar;
$car->color = $color;
$car->setPrice($price);
$car->setMaxspeed($maxSpeed);
return $car;
}
示例10: buyCar
public function buyCar(Car $car)
{
if ($this->money >= $car->getPrice()) {
$this->money -= $car->getPrice();
echo ' Purchase successful!', PHP_EOL;
$this->car = $car;
$car->changeOwner($this);
return $this->money;
} else {
echo ' You need more money! ';
}
}
示例11: buyCar
public function buyCar($car)
{
$car = new Car();
$carPrice = $car->getPrice();
//return $car->getModel;
if ($this->money > $carPrice) {
$this->ownedCar = $car;
return $carPrice;
//$this->money -= $carPrice;
} else {
return $this->money;
}
}
示例12: shouldBeAbleToPopulateByJSON
/**
* @test
*/
public function shouldBeAbleToPopulateByJSON()
{
// given
$car = new Car(1);
$this->assertEquals(1, $car->getId());
$json = $car;
$array = json_decode($json, true);
// when
$array['brand'] = 'BMW';
$car->setValues($array);
$car->commit();
$newCar = new Car(1);
// then
$this->assertEquals('BMW', $newCar->getBrand());
}
示例13: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Car::create([]);
}
}
示例14: run
public function run()
{
$faker = Faker::create();
$parking_lot = ParkingLot::all()->random();
$car = Car::all()->random();
$order = new Order();
$order->parking_lot_id = $parking_lot->id;
$order->car_id = $car->id;
$order->stripe_customer_id = $faker->swiftBicNumber;
$order->save();
$parking_lot = ParkingLot::all()->random();
$car = Car::all()->random();
$order2 = new Order();
$order2->parking_lot_id = $parking_lot->id;
$order2->car_id = $car->id;
$order2->stripe_customer_id = $faker->swiftBicNumber;
$order2->save();
$parking_lot = ParkingLot::all()->random();
$car = Car::all()->random();
$order3 = new Order();
$order3->parking_lot_id = $parking_lot->id;
$order3->car_id = $car->id;
$order3->stripe_customer_id = $faker->swiftBicNumber;
$order3->save();
}
示例15: getAsArray
public function getAsArray($redundantly = false)
{
if (isset($this->id) && (int) $this->id > 0) {
$content = array();
if (!is_null($this->text)) {
$content['text'] = $this->text;
} else {
if (!is_null($this->image_id)) {
$domain = 'http' . (Request::server('HTTPS') ? '' : 's') . '://' . Request::server('HTTP_HOST');
$attachment = MessageAttachment::find($this->image_id);
$content['image'] = array('id' => (int) $attachment->id, 'thumb' => $domain . '/api/messages/attach/thumb/' . $attachment->id, 'origin' => $domain . '/api/messages/attach/gallery/' . $attachment->id, 'width' => $attachment->width, 'height' => $attachment->height);
} else {
if (!is_null($this->car_id)) {
$car = Car::withTrashed()->find($this->car_id);
$content['car'] = array('id' => (int) $car->id, 'mark' => (int) $car->mark, 'model' => (int) $car->model, 'year' => (int) $car->year, 'color' => (int) $car->color, 'vehicle_type' => (int) $car->vehicle_type, 'body_type' => (int) $car->body_type);
if (!is_null($this->car_number)) {
$content['car']['number'] = $this->car_number;
}
} else {
if (!is_null($this->lat)) {
$content['geo'] = array('lat' => (double) $this->lat, 'long' => (double) $this->lng, 'location' => $this->location);
}
}
}
}
if ($redundantly) {
$user = User::find($this->user_id);
return array('message_id' => (int) $this->id, 'chat_id' => (int) $this->chat_id, 'user' => array('id' => (int) $user->id, 'name' => $user->name, 'img' => array('middle' => $user->img_middle)), 'content' => $content, 'timestamp' => $this->getTimestamp(), 'delivered_at' => $this->delivered_at, 'viewed_at' => $this->viewed_at);
} else {
return array('message_id' => (int) $this->id, 'chat_id' => (int) $this->chat_id, 'user_id' => (int) $this->user_id, 'content' => $content, 'timestamp' => $this->getTimestamp(), 'delivered_at' => $this->delivered_at, 'viewed_at' => $this->viewed_at);
}
}
return array();
}