Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/dceprojects.corals.io/vendor/spatie/phpunit-snapshot-assertions/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/dceprojects.corals.io/vendor/spatie/phpunit-snapshot-assertions/src/Filesystem.php
<?php

namespace Spatie\Snapshots;

class Filesystem
{
    /** @var string */
    private $basePath;

    public function __construct(string $basePath)
    {
        $this->basePath = $basePath;
    }

    public static function inDirectory(string $path): self
    {
        return new self($path);
    }

    public function path(string $filename): string
    {
        return $this->basePath.DIRECTORY_SEPARATOR.$filename;
    }

    public function has(string $filename): bool
    {
        return file_exists($this->path($filename));
    }

    /*
     * Get all file names in this directory that have the same name
     * as $fileName, but have a different file extension.
     */
    public function getNamesWithDifferentExtension(string $fileName): array
    {
        if (! file_exists($this->basePath)) {
            return [];
        }

        $extension = pathinfo($fileName, PATHINFO_EXTENSION);

        $baseName = substr($fileName, 0, strlen($fileName) - strlen($extension) - 1);

        $allNames = scandir($this->basePath);

        $namesWithDifferentExtension = array_filter($allNames, function ($existingName) use ($baseName, $extension) {
            $existingExtension = pathinfo($existingName, PATHINFO_EXTENSION);

            $existingBaseName = substr($existingName, 0, strlen($existingName) - strlen($existingExtension) - 1);

            return $existingBaseName === $baseName && $existingExtension !== $extension;
        });

        return array_values($namesWithDifferentExtension);
    }

    public function read(string $filename): string
    {
        return file_get_contents($this->path($filename));
    }

    public function put(string $filename, string $contents): void
    {
        if (! file_exists($this->basePath)) {
            mkdir($this->basePath, 0777, true);
            chmod($this->basePath, 0777);
        }

        file_put_contents($this->path($filename), $contents);
        chmod($this->path($filename), 0666);
    }

    public function delete(string $fileName): bool
    {
        return unlink($this->path($fileName));
    }

    public function copy(string $filePath, string $fileName): void
    {
        if (! file_exists($this->basePath)) {
            mkdir($this->basePath, 0777, true);
            chmod($this->basePath, 0777);
        }

        copy($filePath, $this->path($fileName));
        chmod($this->path($fileName), 0666);
    }

    public function fileEquals(string $filePath, string $fileName): bool
    {
        return sha1_file($filePath) === sha1_file($this->path($fileName));
    }
}

Spamworldpro Mini