IntlBundleReader example

public function __construct(BundleCompilerInterface $compiler, string $dirName)
    {
        $this->compiler = $compiler;
        $this->dirName = $dirName;
    }

    public function generateData(GeneratorConfig $config): void
    {
        $filesystem = new Filesystem();
        $localeScanner = new LocaleScanner();
        $reader = new BundleEntryReader(new IntlBundleReader());

        $writers = $config->getBundleWriters();
        $tempDir = sys_get_temp_dir().'/icu-data-'.$this->dirName;

        // Prepare filesystem directories         foreach ($writers as $targetDir => $writer) {
            $filesystem->remove($targetDir.'/'.$this->dirName);
            $filesystem->mkdir($targetDir.'/'.$this->dirName);
        }

        $filesystem->remove($tempDir);
        
/** * @author Bernhard Schussek <bschussek@gmail.com> * * @requires extension intl */
class IntlBundleReaderTest extends TestCase
{
    private IntlBundleReader $reader;

    protected function setUp(): void
    {
        $this->reader = new IntlBundleReader();
    }

    public function testReadReturnsArrayAccess()
    {
        $data = $this->reader->read(__DIR__.'/Fixtures/res', 'ro');

        $this->assertInstanceOf(\ArrayAccess::class$data);
        $this->assertSame('Bar', $data['Foo']);
        $this->assertArrayNotHasKey('ExistsNot', $data);
    }

    
Home | Imprint | This part of the site doesn't use cookies.