• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Car类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Car的典型用法代码示例。如果您正苦于以下问题:PHP Car类的具体用法?PHP Car怎么用?PHP Car使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Car类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: buyCar

 public function buyCar(Car $car)
 {
     if ($this->getMoney() >= $car->getPrice()) {
         $this->setMoney($this->getMoney() - $car->getPrice());
         $this->setCar($car);
     }
 }
开发者ID:gpichurov,项目名称:ittalents_season5,代码行数:7,代码来源:Person.php


示例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;
 }
开发者ID:0x3e,项目名称:cars,代码行数:26,代码来源:cars.php


示例3: testBridge

 public function testBridge()
 {
     $expect = "SssuuuuZzzuuuuKkiiiii";
     $car = new Car(new EngineSuzuki());
     $sound = $car->rase();
     $this->assertEquals($sound, $expect);
 }
开发者ID:AlexanderGrom,项目名称:php-patterns,代码行数:7,代码来源:bridge_test.php


示例4: isStreetLegal

 protected function isStreetLegal(Car $car)
 {
     if ($car->getMaximumSpeed() < $this->speedLimit) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:ZSShang,项目名称:mylearn,代码行数:8,代码来源:Abstract01.php


示例5: copy

 public function copy()
 {
     $car = new Car();
     $car->setBody($this->getBody());
     $car->setWheel($this->getWheel());
     $car->setEngine($this->getEngine());
     return $car;
 }
开发者ID:nahidacm,项目名称:designpatterns,代码行数:8,代码来源:prototype.php


示例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();
 }
开发者ID:karaatli,项目名称:the-learn-d-developer-design-patterns,代码行数:8,代码来源:AbstractFactoryTests.php


示例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);
 }
开发者ID:ruchidesai,项目名称:MyCakeApp,代码行数:9,代码来源:CarTest.php


示例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());
 }
开发者ID:raynaldmo,项目名称:php-education,代码行数:10,代码来源:car_tests.php


示例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;
 }
开发者ID:ivanstoykovivanov,项目名称:IT_Talents_Homework_Classes,代码行数:10,代码来源:Car.php


示例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! ';
     }
 }
开发者ID:nicoleip,项目名称:OOP_Homework,代码行数:12,代码来源:Person.php


示例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;
     }
 }
开发者ID:ivanstoykovivanov,项目名称:IT_Talents_Homework_Classes,代码行数:13,代码来源:Person.php


示例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());
 }
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:18,代码来源:JSONTest.php


示例13: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Car::create([]);
     }
 }
开发者ID:kenkode,项目名称:umash-1,代码行数:7,代码来源:CarsTableSeeder.php


示例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();
 }
开发者ID:Park-It,项目名称:parkit.dev,代码行数:25,代码来源:OrdersTableSeeder.php


示例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();
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:34,代码来源:Message.php


示例16: updateCars

 function updateCars()
 {
     $carsId = implode(',', $this->curShowCarsId);
     Car::update_all(array('conditions' => 'id in(' . $carsId . ')', 'set' => 'count_visit = count_visit+1'));
     $this->lastCars->cars_id = $carsId;
     $this->lastCars->save();
 }
开发者ID:k-integer,项目名称:2cars,代码行数:7,代码来源:showcar.php


示例17: loadModel

 protected function loadModel($id)
 {
     $model = Car::model()->findByPk($id);
     if (empty($model)) {
         throw new CHttpException(404, 'ผิดพลาดการดึงข้อมูลรถ ลองใหม่อีกครั้ง');
     }
     return $model;
 }
开发者ID:vasitjuntong,项目名称:carsnru,代码行数:8,代码来源:CarListController.php


示例18: run

 public function run()
 {
     $faker = Faker::create();
     Car::truncate();
     foreach (range(1, 11) as $index) {
         Car::create(['user_id' => $index, 'mark' => $faker->word, 'model' => $faker->word, 'year' => $faker->hexcolor, 'color' => $faker->colorName, 'transmission' => $faker->word, 'body' => $faker->word, 'number' => $faker->word]);
     }
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:8,代码来源:CarsTableSeeder.php


示例19: getBookCar

 public function getBookCar()
 {
     $car = Car::find(Input::get('id'));
     if ($car) {
         return View::make('store.booking')->with('car', Car::find(Input::get('id')));
     }
     return Redirect::to('/')->with('message', 'invalid car id, please try again');
 }
开发者ID:madiarsa,项目名称:laravel-4.1-car-rental-site,代码行数:8,代码来源:StoreController.php


示例20: hasDone

 public static function hasDone($uid)
 {
     $car = Car::findFirst("uid={$uid}");
     if (!$car) {
         return false;
     }
     $advises = Advise::getAdvisesByUid($uid, Advise::STATUS_UNDO, 'car');
     return $advises ? false : true;
 }
开发者ID:Crocodile26,项目名称:php-1,代码行数:9,代码来源:Car.php



注:本文中的Car类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Carbon类代码示例发布时间:2022-05-20
下一篇:
PHP Captcha类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap