PHP 8.2.31
Preview: Wappspector.php Size: 1.01 KB
//opt/cpanel/ea-wappspector/src/Wappspector.php

<?php

namespace Plesk\Wappspector;

use Plesk\Wappspector\Matchers\MatcherInterface;
use Plesk\Wappspector\MatchResult\EmptyMatchResult;
use Plesk\Wappspector\MatchResult\MatchResultInterface;
use Throwable;

final class Wappspector
{
    /**
     * @param callable $fsFactory
     */
    public function __construct(private $fsFactory, private array $matchers)
    {
    }

    /**
     * @return MatchResultInterface[]
     * @throws Throwable
     */
    public function run(string $path, string $basePath = '/', int $matchersLimit = 0): iterable
    {
        $fs = ($this->fsFactory)($basePath);

        $result = [];

        /** @var MatcherInterface $matcher */
        foreach ($this->matchers as $matcher) {
            if (($match = $matcher->match($fs, $path)) instanceof EmptyMatchResult) {
                continue;
            }

            $result[] = $match;
            if ($matchersLimit > 0 && count($result) >= $matchersLimit) {
                break;
            }
        }

        return $result;
    }
}

Directory Contents

Dirs: 4 × Files: 4

Name Size Perms Modified Actions
Command DIR
- drwxr-xr-x 2026-05-15 07:01:45
Edit Download
Helper DIR
- drwxr-xr-x 2026-05-15 07:01:45
Edit Download
Matchers DIR
- drwxr-xr-x 2026-05-15 07:01:45
Edit Download
- drwxr-xr-x 2026-05-15 07:01:45
Edit Download
1.83 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
384 B lrw-r--r-- 2026-05-14 15:20:35
Edit Download
364 B lrw-r--r-- 2026-05-14 15:20:35
Edit Download
1.01 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).