class PharExtensionInterceptor

Same name in this branch
  1. 7.x misc/typo3/drupal-security/PharExtensionInterceptor.php \Drupal\Core\Security\PharExtensionInterceptor
Same name in other branches
  1. 9 core/lib/Drupal/Core/Security/PharExtensionInterceptor.php \Drupal\Core\Security\PharExtensionInterceptor
  2. 8.9.x core/lib/Drupal/Core/Security/PharExtensionInterceptor.php \Drupal\Core\Security\PharExtensionInterceptor

Hierarchy

Expanded class hierarchy of PharExtensionInterceptor

File

misc/typo3/phar-stream-wrapper/src/Interceptor/PharExtensionInterceptor.php, line 18

Namespace

TYPO3\PharStreamWrapper\Interceptor
View source
class PharExtensionInterceptor implements Assertable {
    
    /**
     * Determines whether the base file name has a ".phar" suffix.
     *
     * @param string $path
     * @param string $command
     * @return bool
     * @throws Exception
     */
    public function assert($path, $command) {
        if ($this->baseFileContainsPharExtension($path)) {
            return true;
        }
        throw new Exception(sprintf('Unexpected file extension in "%s"', $path), 1535198703);
    }
    
    /**
     * @param string $path
     * @return bool
     */
    private function baseFileContainsPharExtension($path) {
        $invocation = Manager::instance()->resolve($path);
        if ($invocation === null) {
            return false;
        }
        $fileExtension = pathinfo($invocation->getBaseName(), PATHINFO_EXTENSION);
        return strtolower($fileExtension) === 'phar';
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
PharExtensionInterceptor::assert public function Determines whether the base file name has a ".phar" suffix. Overrides Assertable::assert
PharExtensionInterceptor::baseFileContainsPharExtension private function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.