當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Finder::findRecipe方法代碼示例

本文整理匯總了PHP中Finder::findRecipe方法的典型用法代碼示例。如果您正苦於以下問題:PHP Finder::findRecipe方法的具體用法?PHP Finder::findRecipe怎麽用?PHP Finder::findRecipe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Finder的用法示例。


在下文中一共展示了Finder::findRecipe方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testFindRecipeFunction

 public function testFindRecipeFunction()
 {
     $fridge = $this->getFridge();
     $idealRecipes = $this->getRecipesData();
     $finder = new Finder($fridge);
     $result1 = $finder->findRecipe($idealRecipes);
     $this->assertEquals($result1, 'grilled cheese on toast');
     $newRecipe2 = array('name' => 'extra cheese and peanut butter on bread', 'ingredients' => array(0 => array('item' => 'bread', 'amount' => '2', 'unit' => 'slices'), 1 => array('item' => 'cheese', 'amount' => '10', 'unit' => 'slices'), 2 => array('item' => 'peanut butter', 'amount' => '250', 'unit' => 'grams')));
     $result2 = $finder->findRecipe(array_merge($idealRecipes, array($newRecipe2)));
     $this->assertEquals($result2, 'extra cheese and peanut butter on bread');
     $newRecipe3 = array('name' => 'expired salad', 'ingredients' => array(0 => array('item' => 'mixed salad', 'amount' => '200', 'unit' => 'grams')));
     $result3 = $finder->findRecipe(array($newRecipe3));
     $this->assertEquals($result3, 'Order Takeout');
 }
開發者ID:y2khjh,項目名稱:test1,代碼行數:14,代碼來源:FinderTest.php

示例2: main

function main()
{
    $fridge_csv_path = isset($argv[1]) ? $argv[1] : 'fridge.csv';
    $recipe_json_path = isset($argv[2]) ? $argv[2] : 'recipes.js';
    $ingredients = array_map('str_getcsv', file($fridge_csv_path));
    $recipes = json_decode(file_get_contents($recipe_json_path), 1);
    $fridge = new Fridge();
    $fridge->fillFromArray($ingredients);
    $finder = new Finder($fridge);
    $recipeToday = $finder->findRecipe($recipes);
    echo $recipeToday . "\n";
}
開發者ID:y2khjh,項目名稱:test1,代碼行數:12,代碼來源:Main.php


注:本文中的Finder::findRecipe方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。