$17 GRAYBYTE WORDPRESS FILE MANAGER $94

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.217.254 | ADMIN IP 216.73.216.180
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : mail

/opt/alt/php55/usr/share/pear/Symfony/Component/Finder/Iterator/

HOME
Current File : /opt/alt/php55/usr/share/pear/Symfony/Component/Finder/Iterator//SortableIterator.php
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Finder\Iterator;

/**
 * SortableIterator applies a sort on a given Iterator.
 *
 * @author Fabien Potencier <[email protected]>
 */
class SortableIterator implements \IteratorAggregate
{
    const SORT_BY_NAME = 1;
    const SORT_BY_TYPE = 2;
    const SORT_BY_ACCESSED_TIME = 3;
    const SORT_BY_CHANGED_TIME = 4;
    const SORT_BY_MODIFIED_TIME = 5;

    private $iterator;
    private $sort;

    /**
     * Constructor.
     *
     * @param \Traversable     $iterator The Iterator to filter
     * @param integer|callback $sort     The sort type (SORT_BY_NAME, SORT_BY_TYPE, or a PHP callback)
     *
     * @throws \InvalidArgumentException
     */
    public function __construct(\Traversable $iterator, $sort)
    {
        $this->iterator = $iterator;

        if (self::SORT_BY_NAME === $sort) {
            $this->sort = function ($a, $b) {
                return strcmp($a->getRealpath(), $b->getRealpath());
            };
        } elseif (self::SORT_BY_TYPE === $sort) {
            $this->sort = function ($a, $b) {
                if ($a->isDir() && $b->isFile()) {
                    return -1;
                } elseif ($a->isFile() && $b->isDir()) {
                    return 1;
                }

                return strcmp($a->getRealpath(), $b->getRealpath());
            };
        } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
            $this->sort = function ($a, $b) {
                return ($a->getATime() > $b->getATime());
            };
        } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
            $this->sort = function ($a, $b) {
                return ($a->getCTime() > $b->getCTime());
            };
        } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
            $this->sort = function ($a, $b) {
                return ($a->getMTime() > $b->getMTime());
            };
        } elseif (is_callable($sort)) {
            $this->sort = $sort;
        } else {
            throw new \InvalidArgumentException('The SortableIterator takes a PHP callback or a valid built-in sort algorithm as an argument.');
        }
    }

    public function getIterator()
    {
        $array = iterator_to_array($this->iterator, true);
        uasort($array, $this->sort);

        return new \ArrayIterator($array);
    }
}


Current_dir [ NOT WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
3 Mar 2024 10.54 PM
root / root
0755
CustomFilterIterator.php
1.508 KB
18 Dec 2019 11.24 AM
root / root
0644
DateRangeFilterIterator.php
1.427 KB
18 Dec 2019 11.24 AM
root / root
0644
DepthRangeFilterIterator.php
1.235 KB
18 Dec 2019 11.24 AM
root / root
0644
ExcludeDirectoryFilterIterator.php
1.402 KB
18 Dec 2019 11.24 AM
root / root
0644
FilePathsIterator.php
2.643 KB
18 Dec 2019 11.24 AM
root / root
0644
FileTypeFilterIterator.php
1.346 KB
18 Dec 2019 11.24 AM
root / root
0644
FilecontentFilterIterator.php
1.904 KB
18 Dec 2019 11.24 AM
root / root
0644
FilenameFilterIterator.php
1.685 KB
18 Dec 2019 11.24 AM
root / root
0644
FilterIterator.php
1.405 KB
18 Dec 2019 11.24 AM
root / root
0644
MultiplePcreFilterIterator.php
1.732 KB
18 Dec 2019 11.24 AM
root / root
0644
PathFilterIterator.php
1.914 KB
18 Dec 2019 11.24 AM
root / root
0644
RecursiveDirectoryIterator.php
2.976 KB
18 Dec 2019 11.24 AM
root / root
0644
SizeRangeFilterIterator.php
1.411 KB
18 Dec 2019 11.24 AM
root / root
0644
SortableIterator.php
2.485 KB
18 Dec 2019 11.24 AM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF