Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -17,13 +17,19 @@ namespace Sly\NotificationPusher\Collection;
* @uses \IteratorAggregate
* @author Cédric Dugat <cedric@dugat.me>
*/
abstract class AbstractCollection
abstract class AbstractCollection implements \IteratorAggregate, \Countable
{
/**
* @var \ArrayIterator
*/
protected $coll;
/**
* @inheritdoc
* @return \ArrayIterator|\SeekableIterator
*/
abstract public function getIterator();
/**
* Get.
*
@@ -43,7 +49,7 @@ abstract class AbstractCollection
*/
public function count()
{
return count($this->getIterator());
return $this->getIterator()->count();
}
/**
@@ -63,4 +69,38 @@ abstract class AbstractCollection
{
$this->coll = new \ArrayIterator();
}
/**
* @return mixed|null
*/
public function first()
{
$tmp = clone $this->coll;
//go to the beginning
$tmp->rewind();
if (!$tmp->valid()) {
return null;
}
return $tmp->current();
}
/**
* @return mixed|null
*/
public function last()
{
$tmp = clone $this->coll;
//go to the end
$tmp->seek($tmp->count() - 1);
if (!$tmp->valid()) {
return null;
}
return $tmp->current();
}
}

View File

@@ -20,7 +20,7 @@ use Sly\NotificationPusher\Model\PushInterface;
* @uses \IteratorAggregate
* @author Cédric Dugat <cedric@dugat.me>
*/
class PushCollection extends AbstractCollection implements \IteratorAggregate
class PushCollection extends AbstractCollection
{
/**
* Constructor.

View File

@@ -0,0 +1,49 @@
<?php
/*
* This file is part of NotificationPusher.
*
* (c) 2016 Lukas Klinzing <theluk@gmail.com>
* (c) 2013 Cédric Dugat <cedric@dugat.me>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sly\NotificationPusher\Collection;
/**
* Response Collection.
* is just a container for a response from a push service
*
* @uses \Sly\NotificationPusher\Collection\AbstractCollection
* @uses \IteratorAggregate
* @author Lukas Klinzing <theluk@gmail.com>
*/
class ResponseCollection extends AbstractCollection
{
/**
* Constructor.
*/
public function __construct()
{
$this->coll = new \ArrayIterator();
}
/**
* @return \ArrayIterator
*/
public function getIterator()
{
return $this->coll;
}
/**
* @param string $token
* @param mixed $response
*/
public function add($token, $response)
{
$this->coll[$token] = $response;
}
}