本文整理汇总了PHP中Arr::subset方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::subset方法的具体用法?PHP Arr::subset怎么用?PHP Arr::subset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::subset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConfig
/**
* Get config
*
* @param mixed $key Config key
* @param mixed $default Default value
*
* @return mixed Config setting value or the whole config array
*/
public function getConfig($key = null, $default = null)
{
if (is_array($key)) {
return \Arr::subset($this->config, $key, $default);
}
return \Arr::get($this->config, $key, $default);
}
示例2: test_subset_missing_items
/**
* Tests Arr::subset()
*
* @test
* @dataProvider person_provider
*/
public function test_subset_missing_items($person)
{
$expected = array("name" => "Jack", "location" => array("street" => null, "country" => "US"), "occupation" => null);
$got = \Arr::subset($person, array("name", "location.street", "location.country", "occupation"));
$this->assertEquals($expected, $got);
$expected = array("name" => "Jack", "location" => array("street" => "Unknown", "country" => "US"), "occupation" => "Unknown");
$got = \Arr::subset($person, array("name", "location.street", "location.country", "occupation"), "Unknown");
$this->assertEquals($expected, $got);
}