"Fossies" - the Fresh Open Source Software Archive

Member "grav/system/src/Grav/Common/GPM/Common/AbstractPackageCollection.php" (8 Jun 2020, 750 Bytes) of package /linux/www/grav-v1.6.26.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AbstractPackageCollection.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 /**
    4  * @package    Grav\Common\GPM
    5  *
    6  * @copyright  Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
    7  * @license    MIT License; see LICENSE file for details.
    8  */
    9 
   10 namespace Grav\Common\GPM\Common;
   11 
   12 use Grav\Common\Iterator;
   13 
   14 abstract class AbstractPackageCollection extends Iterator
   15 {
   16     protected $type;
   17 
   18     public function toJson()
   19     {
   20         $items = [];
   21 
   22         foreach ($this->items as $name => $package) {
   23             $items[$name] = $package->toArray();
   24         }
   25 
   26         return json_encode($items);
   27     }
   28 
   29     public function toArray()
   30     {
   31         $items = [];
   32 
   33         foreach ($this->items as $name => $package) {
   34             $items[$name] = $package->toArray();
   35         }
   36 
   37         return $items;
   38     }
   39 }