public function testFirstAndLast() { $this->_coll->add('one'); $this->_coll->add('two'); $this->assertEquals($this->_coll->first(), 'one'); $this->assertEquals($this->_coll->last(), 'two'); }
/** * {@inheritdoc} */ public function getImage() { if ($this->images->isEmpty()) { return $this->getProduct()->getImage(); } return $this->images->first(); }
/** * {@inheritdoc} */ public function getImage() { if ($this->images->isEmpty()) { return null; } return $this->images->first(); }
/** * Get filename of the first document signature * * @return null|string */ public function getFirstDocumentSignatureFilename() { if ($this->getDocumentSignaturesCount() > 0) { /** @var DocumentSignature $signature */ $signature = $this->documentSignatures->first(); return $signature->getDocument()->getFilename(); } return null; }
function it_adds_new_item_units_to_existing_shipment(OrderInterface $order, ShipmentInterface $shipment, Collection $shipments, OrderItemUnitInterface $itemUnit, OrderItemUnitInterface $itemUnitWithoutShipment) { $shipments->first()->willReturn($shipment); $order->hasShipments()->willReturn(true); $order->getItemUnits()->willReturn([$itemUnit, $itemUnitWithoutShipment]); $order->getShipments()->willReturn($shipments); $itemUnit->getShipment()->willReturn($shipment); $shipment->addUnit($itemUnitWithoutShipment)->shouldBeCalled(); $shipment->addUnit($itemUnit)->shouldNotBeCalled(); $this->processOrderShipment($order); }
/** * Gets the last updated shipment of the order * * @return false|ShipmentInterface */ public function getLastShipment() { if ($this->shipments->isEmpty()) { return false; } $last = $this->shipments->first(); foreach ($this->shipments as $shipment) { if ($shipment->getUpdatedAt() > $last->getUpdatedAt()) { $last = $shipment; } } return $last; }
/** * @param Collection|TaxonomyTermInterface[] $collection * @return TaxonomyTermInterface|null */ public function findBranch(Collection $collection) { if (empty($collection)) { return null; } $maxDepth = 9999; $item = $collection->first(); foreach ($collection as $term) { $depth = $this->iterBranch($term, $maxDepth); if ($depth < $maxDepth) { $maxDepth = $depth; $item = $term; } } return $item; }
/** * Generates the cells. * * @param TableView $view */ private function generateCells(TableView $view) { $sortDirs = [ColumnSort::ASC, ColumnSort::DESC]; $columns = $this->config->getColumns(); foreach ($columns as &$columnOptions) { $key = $columnOptions['full_name'] . '_sort'; $sortDir = $this->requestHelper->getVar($key, ColumnSort::NONE); $columnOptions['sorted'] = in_array($sortDir, $sortDirs); } unset($columnOptions); $this->data->first(); while ($this->data->current()) { $row = new Row($this->getCurrentRowData('id')); // TODO getCurrentRowKey() ? foreach ($columns as $columnOptions) { $cell = new Cell(); $type = $this->factory->getColumnType($columnOptions['type']); $type->buildViewCell($cell, $this, $columnOptions); $row->cells[] = $cell; } $view->rows[] = $row; $this->data->next(); } }
/** * @dataProvider provideCollection */ public function testContains(Collection $coll, array $elements) { $this->assertTrue($coll->contains($coll->first())); $this->assertFalse($coll->contains(new \stdClass())); }
/** * {@inheritdoc} */ public function first() { return $this->inner->first(); }
/** * {@inheritdoc} */ public function getFirstChild() { return $this->children->first(); }
/** {@inheritdoc} */ public function first() { $this->initialize(); return $this->coll->first(); }
/** * {@inheritDoc} */ public function first() { return $this->collection->first(); }
/** * @dataProvider provideCollection */ public function testFirst(Collection $coll, array $elements) { $this->assertSame(reset($elements), $coll->first()); }
/** * @return bool */ public function hasOfferVariants() { if (count($this->quoteProductOffers) > 1) { return true; } /** @var QuoteProductOffer $firstItem */ $firstItem = $this->quoteProductOffers->first(); return $firstItem && $firstItem->isAllowIncrements(); }
/** * Sets the internal iterator to the first element in the collection and returns this element. * * @return mixed */ function first() { $this->initialize(); $first = $this->collection->first(); return $first->getTerm(); }
/** * @param Collection $orderedByIndex * @return bool */ protected function isIncreasing(Collection $orderedByIndex) { return is_null($orderedByIndex->first()->getMinValue()) && is_null($orderedByIndex->last()->getMaxValue()); }
public function getCity() { if ($this->lessons->count() > 0) { return $this->lessons->first()->getCity(); } }
public function rewind() { $this->_data->first(); }