Laravel version update
Laravel version update
This commit is contained in:
		| @@ -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(); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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. | ||||
|   | ||||
							
								
								
									
										49
									
								
								vendor/sly/notification-pusher/src/Sly/NotificationPusher/Collection/ResponseCollection.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								vendor/sly/notification-pusher/src/Sly/NotificationPusher/Collection/ResponseCollection.php
									
									
									
									
										vendored
									
									
										Normal 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; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Manish Verma
					Manish Verma