本文整理汇总了PHP中Collection::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::get方法的具体用法?PHP Collection::get怎么用?PHP Collection::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGet
/**
* @test Collection::get()
*/
public function testGet()
{
$this->buildEnvironment();
$result = $this->collection->get('a1');
$expect = $this->source['a1'];
$this->assertEquals($expect, $result);
}
示例2: testPopPushPutShiftUnshiftInject
public function testPopPushPutShiftUnshiftInject()
{
// pop
$_3 = $this->collection->pop();
$this->assertEquals($this->_3, $_3);
$this->assertEquals($this->_2, $this->collection->last());
$this->assertEquals(3, $this->collection->count());
// push
$this->collection->push($_3);
$this->assertEquals($this->_3, $this->collection->last());
// put
$this->collection->put(2, 'test');
$this->assertEquals('test', $this->collection->get(2));
// shift
$_0 = $this->collection->shift();
$this->assertEquals($this->_0, $_0);
$this->assertEquals($this->_1, $this->collection->first());
$this->assertEquals(3, $this->collection->count());
// unshift
$this->collection->unshift($_0);
$this->assertEquals($this->_0, $this->collection->first());
// inject
$this->collection->inject(2, 'test2');
$this->assertEquals('test2', $this->collection->get(2));
$this->assertEquals(5, $this->collection->count());
}
示例3: appendChildren
private function appendChildren(Aggregate $entity, CollectionInterface $children) : Aggregate
{
$children->each(function (string $name, array $config) use(&$entity) {
$config = new Collection($config);
$rel = new ValueObjectRelationship(new ClassName($config->get('class')), new RelationshipType($config->get('type')), $name, $config->get('child')['property'], $config->hasKey('collection') ? (bool) $config->get('collection') : false);
if ($config->hasKey('properties')) {
$rel = $this->appendProperties($rel, new Collection($config->get('properties')));
}
$config = new Collection($config->get('child'));
$child = new ValueObject(new ClassName($config->get('class')), $config->get('labels'), $rel);
if ($config->hasKey('properties')) {
$child = $this->appendProperties($child, new Collection($config->get('properties')));
}
$entity = $entity->withChild($child);
});
return $entity;
}
示例4: findImageSize
/**
* Find image size data
*
* @param string $sizeName
* @return ImageSize
*/
public function findImageSize($sizeName)
{
if ($this->imageSizes->containsKey($sizeName)) {
return $this->imageSizes->get($sizeName);
} else {
return null;
}
}
示例5: get
/**
* /
* @param [type] $id [description]
* @return [type] [description]
*/
public function get($id)
{
if (!is_string($id)) {
throw new \Exception("Cookie index must be string", 03);
}
$newId = str_replace('.', '_', $id);
$value = parent::get($newId);
return new Cookie($value);
}
示例6: get
public function get($key = '', $defVal = null)
{
if (stripos($key, '.') !== false) {
list($parentKey) = explode('.', $key);
if (!array_key_exists($parentKey, $this->_loadedFiles)) {
$this->_loadFile($parentKey);
}
}
return parent::get($key, $defVal);
}
示例7: testGetsElementByIndex
public function testGetsElementByIndex()
{
$list = new Collection(\Cassandra::TYPE_VARINT);
$list->add(new Varint('1'), new Varint('2'), new Varint('3'), new Varint('4'), new Varint('5'), new Varint('6'), new Varint('7'), new Varint('8'));
$this->assertEquals(new Varint('1'), $list->get(0));
$this->assertEquals(new Varint('2'), $list->get(1));
$this->assertEquals(new Varint('3'), $list->get(2));
$this->assertEquals(new Varint('4'), $list->get(3));
$this->assertEquals(new Varint('5'), $list->get(4));
$this->assertEquals(new Varint('6'), $list->get(5));
$this->assertEquals(new Varint('7'), $list->get(6));
$this->assertEquals(new Varint('8'), $list->get(7));
}
示例8: get_instance_title
/**
* Optional method. If exists, allows this class to decide the title for
* all blockinstances of this type
*/
public static function get_instance_title(BlockInstance $bi)
{
$configdata = $bi->get('configdata');
if (!empty($configdata['collection'])) {
require_once 'collection.php';
$data = get_record_select('collection', 'id = ?', array($configdata['collection']));
$collection = new Collection($configdata['collection'], (array) $data);
$title = $collection->get('name');
return $title;
}
return '';
}
示例9: handler_participants
protected function handler_participants(Collection $activities, $fields)
{
$res = XDB::iterator('SELECT id, participant
FROM activities_participants
WHERE id IN {?}', $activities->ids());
$users = new Collection('User');
$part = array();
while ($datas = $res->next()) {
$part[$datas['id']][] = $users->addget($datas['participant']);
}
foreach ($part as $key => $obj) {
$activities->get($key)->participants($obj);
}
$users->select($this->subs['participants']);
}
示例10: encode
public function encode($script)
{
$this->search($script);
$this->words->sort();
$encoded = new Collection();
// a dictionary of base62 -> base10
$size = $this->words->size();
for ($i = 0; $i < $size; $i++) {
$encoded->put(Packer::encode62($i), $i);
}
$index = 0;
foreach ($this->words as $word) {
if ($encoded->has($word)) {
$word->index = $encoded->get($word);
$word->clear();
} else {
while ($this->words->has(Packer::encode62($index))) {
$index++;
}
$word->index = $index++;
if ($word->count == 1) {
$word->clear();
}
}
$word->replacement = Packer::encode62($word->index);
if (strlen($word->replacement) == strlen($word)) {
$word->clear();
}
}
// sort by encoding
$this->words->sort(array('Base62', 'sorter'));
// trim unencoded words
$this->words = $this->words->slice(0, preg_match_all('/\\|/', $this->getKeyWords(), $matches) + 1);
$script = preg_replace_callback($this->getPattern(), array(&$this, '_word_replacement'), $script);
/* build the packed script */
$p = $this->escape($script);
$a = '[]';
$c = max($this->words->size(), 1);
$k = $this->getKeyWords();
$e = $this->getEncoder();
$d = $this->getDecoder();
// the whole thing
return $this->format(Base62::$UNPACK, $p, $a, $c, $k, $e, $d);
}
示例11: getDoctorsListCount
public function getDoctorsListCount($latitude = 0, $longitude = 0, $query = array())
{
$this->data = DB::table('doctors');
$this->data->leftJoin('doctors_details AS dhospital', 'doctors.id', '=', 'dhospital.doctor_id');
$this->data->leftJoin('listing_hospitals', 'dhospital.detail_id', '=', 'listing_hospitals.id');
$this->data->leftJoin('doctors_details AS dhmo', 'doctors.id', '=', 'dhmo.doctor_id');
$this->data->leftJoin('listing_hmo', 'dhmo.detail_id', '=', 'listing_hmo.id');
$this->data->leftJoin('doctors_specialization', 'doctors.id', '=', 'doctors_specialization.doctor_id');
$this->data->leftJoin('location_cities', 'listing_hospitals.city', '=', 'location_cities.id');
$this->data->leftJoin('location_provinces', 'listing_hospitals.province', '=', 'location_provinces.id');
$this->data->select(DB::raw("doctors.*, dhospital.detail_id as hospital_id, listing_hospitals.listing_title as hospital_title, listing_hospitals.latitude, listing_hospitals.longitude, listing_hospitals.street, location_cities.city_name, location_provinces.province_name, dhmo.detail_id as hmo_id, listing_hmo.listing_title as hmo_title, doctors_specialization.specialization_id, (6371 * acos (cos ( radians(?) ) * cos( radians( listing_hospitals.latitude ) ) * cos( radians( listing_hospitals.longitude ) - radians(?) ) + sin ( radians(?) ) * sin( radians( listing_hospitals.latitude ) ))) AS distance"))->setBindings([$latitude, $longitude, $latitude]);
$this->data->where('dhospital.detail_type', '=', 1);
$this->data->where('dhmo.detail_type', '=', 4);
if (isset($query['specializations'])) {
$this->data->whereIn('doctors_specialization.specialization_id', $query['specializations']);
}
if (isset($query['locations'])) {
$this->data->whereIn('listing_hospitals.city', $query['locations']);
}
$this->data->groupBy('doctors.id');
// }
return $this->data->get();
}
示例12: handler_cuvisibility
/**
* Select a GID which identifies the visibility of a caste-user assocation
*/
protected function handler_cuvisibility(Collection $users, $fields)
{
$_users = array();
foreach ($users as $u) {
$_users[$u->id()] = array();
}
$viscoll = new Collection('Group');
$iter = XDB::iterRow('SELECT uid, cid, visibility
FROM castes_users
WHERE uid IN {?}', $users->ids());
while (list($uid, $cid, $vis) = $iter->next()) {
$_users[$uid][$cid] = $vis;
if ($vis != 0) {
$viscoll->add($vis);
}
}
$viscoll->select(GroupSelect::base());
foreach ($users as $u) {
$cuarray = array_map(function ($gid) use($viscoll) {
return $gid == 0 ? null : $viscoll->get($gid);
}, $_users[$u->id()]);
$u->fillFromArray(array('cuvisibility' => $cuarray));
}
}
示例13: Collection
<?php
$collection = new Collection(['a' => 'apple', 'b' => 'banana', 'c' => 'carrot']);
$collection->get('b');
//
// RETURNS:
//
// 'banana'
//
示例14: get
/**
* {@inheritdoc}
*/
public function get($key)
{
$this->initialize();
return $this->coll->get($key);
}
示例15: isXmlHttpRequest
/**
* Returns true if the request is a XMLHttpRequest.
*
* It works if your JavaScript library set an X-Requested-With HTTP header.
* It is known to work with Prototype, Mootools, jQuery.
*
* @return Boolean true if the request is an XMLHttpRequest, false otherwise
*
* @api
*/
public function isXmlHttpRequest()
{
return 'XMLHttpRequest' == $this->headers->get('X_REQUESTED_WITH');
}