本文整理汇总了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');
}
示例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";
}