vendor/symfony/intl/Data/Bundle/Reader/PhpBundleReader.php line 38

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Intl\Data\Bundle\Reader;
  11. use Symfony\Component\Intl\Exception\ResourceBundleNotFoundException;
  12. /**
  13.  * Reads .php resource bundles.
  14.  *
  15.  * @author Bernhard Schussek <bschussek@gmail.com>
  16.  *
  17.  * @internal
  18.  */
  19. class PhpBundleReader implements BundleReaderInterface
  20. {
  21.     /**
  22.      * {@inheritdoc}
  23.      */
  24.     public function read(string $pathstring $locale)
  25.     {
  26.         $fileName $path.'/'.$locale.'.php';
  27.         // prevent directory traversal attacks
  28.         if (\dirname($fileName) !== $path) {
  29.             throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.'$fileName));
  30.         }
  31.         if (!is_file($fileName)) {
  32.             throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.'$fileName));
  33.         }
  34.         return include $fileName;
  35.     }
  36. }