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