本文整理匯總了PHP中Doctrine\Common\Collections\Collection::partition方法的典型用法代碼示例。如果您正苦於以下問題:PHP Collection::partition方法的具體用法?PHP Collection::partition怎麽用?PHP Collection::partition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\Common\Collections\Collection
的用法示例。
在下文中一共展示了Collection::partition方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testPartition
public function testPartition()
{
$this->_coll[] = true;
$this->_coll[] = false;
$partition = $this->_coll->partition(function ($k, $e) {
return $e == true;
});
$this->assertEquals($partition[0][0], true);
$this->assertEquals($partition[1][0], false);
}
示例2: partition
/**
* {@inheritDoc}
*/
public function partition(Closure $p)
{
$array = $this->toArray();
$this->collection->clear();
foreach ($array as $key => $element) {
$this->collection->set($key, $element);
}
$partitions = $this->collection->partition($p);
return [new static($partitions[0]), new static($partitions[1])];
}
示例3: partition
/**
* {@inheritdoc}
*/
public function partition(Closure $p)
{
$this->initialize();
return $this->coll->partition($p);
}
示例4: partition
/**
* {@inheritdoc}
*/
public function partition(\Closure $p)
{
return $this->inner->partition($p);
}
示例5: testPartitionCreatesCorrectInstance
/**
* @dataProvider provideCollection
*/
public function testPartitionCreatesCorrectInstance(Collection $coll, array $elements)
{
list($match, $noMatch) = $coll->partition(function () {
return true;
});
$this->assertInstanceOf(get_class($coll), $match);
$this->assertInstanceOf(get_class($coll), $noMatch);
$this->assertCount(0, $noMatch);
$this->assertCount(count($elements), $match);
}