Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php declare(strict_types=1); /* * This file is a part of Sculpin. * * (c) Dragonfly..

Decoded Output download

<?php

declare(strict_types=1);

/*
 * This file is a part of Sculpin.
 *
 * (c) Dragonfly Development Inc.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sculpin\Core\Util;

/**
 * @author Beau Simensen <[email protected]>
 */
final class DirectorySeparatorNormalizer
{
    /**
     * @var string
     */
    private $preferredDirectorySeparator;

    /**
     * @var string
     */
    private $directorySeparator;

    public function __construct(string $preferredDirectorySeparator = '/')
    {
        $this->preferredDirectorySeparator = $preferredDirectorySeparator;
        $this->directorySeparator = DIRECTORY_SEPARATOR;
    }

    /**
     * Set directory separator.
     *
     * Useful for testing to override DIRECTORY_SEPARATOR.
     */
    public function setDirectorySeparator(string $directorySeparator): self
    {
        $this->directorySeparator = $directorySeparator;

        return $this;
    }

    /**
     * Normalize filesystem paths to a preferred $separator.
     */
    public function normalize(?string $path): ?string
    {
        if ($this->preferredDirectorySeparator === $this->directorySeparator) {
            return $path;
        }

        if (null === $path) {
            return $path;
        }

        return implode($this->preferredDirectorySeparator, explode($this->directorySeparator, $path));
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

declare(strict_types=1);

/*
 * This file is a part of Sculpin.
 *
 * (c) Dragonfly Development Inc.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sculpin\Core\Util;

/**
 * @author Beau Simensen <[email protected]>
 */
final class DirectorySeparatorNormalizer
{
    /**
     * @var string
     */
    private $preferredDirectorySeparator;

    /**
     * @var string
     */
    private $directorySeparator;

    public function __construct(string $preferredDirectorySeparator = '/')
    {
        $this->preferredDirectorySeparator = $preferredDirectorySeparator;
        $this->directorySeparator = DIRECTORY_SEPARATOR;
    }

    /**
     * Set directory separator.
     *
     * Useful for testing to override DIRECTORY_SEPARATOR.
     */
    public function setDirectorySeparator(string $directorySeparator): self
    {
        $this->directorySeparator = $directorySeparator;

        return $this;
    }

    /**
     * Normalize filesystem paths to a preferred $separator.
     */
    public function normalize(?string $path): ?string
    {
        if ($this->preferredDirectorySeparator === $this->directorySeparator) {
            return $path;
        }

        if (null === $path) {
            return $path;
        }

        return implode($this->preferredDirectorySeparator, explode($this->directorySeparator, $path));
    }
}

Function Calls

None

Variables

None

Stats

MD5 f99cc74dbdcab884824a69c8b1581a45
Eval Count 0
Decode Time 101 ms