From c31a0f696b87f0c6b885784610b4ff05aefb352f Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 1 Nov 2022 16:58:30 +0100 Subject: [PATCH] Use tabs instead of spaces like in FileLoader --- src/Latte/Loaders/NamespaceLoader.php | 102 +++++++++++----------- tests/common/Loaders.NamespaceLoader.phpt | 26 +++--- 2 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/Latte/Loaders/NamespaceLoader.php b/src/Latte/Loaders/NamespaceLoader.php index 803614b91c..c450bbfa21 100644 --- a/src/Latte/Loaders/NamespaceLoader.php +++ b/src/Latte/Loaders/NamespaceLoader.php @@ -17,71 +17,71 @@ */ class NamespaceLoader implements Latte\Loader { - /** - * @var Latte\Loader[] - */ - private array $loaders; + /** + * @var Latte\Loader[] + */ + private array $loaders; - public function __construct(array $loaders) - { - $this->loaders = $loaders; - } + public function __construct(array $loaders) + { + $this->loaders = $loaders; + } - /** - * Returns template source code. - */ - public function getContent(string $name): string - { - [$loader, $name] = $this->extractLoaderAndName($name); + /** + * Returns template source code. + */ + public function getContent(string $name): string + { + [$loader, $name] = $this->extractLoaderAndName($name); - return $loader->getContent($name); - } + return $loader->getContent($name); + } - public function isExpired(string $file, int $time): bool - { - [$loader, $name] = $this->extractLoaderAndName($file); + public function isExpired(string $file, int $time): bool + { + [$loader, $name] = $this->extractLoaderAndName($file); - return $loader->isExpired($name, $time); - } + return $loader->isExpired($name, $time); + } - /** - * Returns referred template name. - */ - public function getReferredName(string $name, string $referringName): string - { - [$loader, $name] = $this->extractLoaderAndName($name); + /** + * Returns referred template name. + */ + public function getReferredName(string $name, string $referringName): string + { + [$loader, $name] = $this->extractLoaderAndName($name); - return $loader->getReferredName($name, $referringName); - } + return $loader->getReferredName($name, $referringName); + } - /** - * Returns unique identifier for caching. - */ - public function getUniqueId(string $name): string - { - [$loader, $name] = $this->extractLoaderAndName($name); + /** + * Returns unique identifier for caching. + */ + public function getUniqueId(string $name): string + { + [$loader, $name] = $this->extractLoaderAndName($name); - return $loader->getUniqueId($name); - } + return $loader->getUniqueId($name); + } - private function extractLoaderAndName(string $name): array - { - $namespaceParts = \explode('::', $name, 2); + private function extractLoaderAndName(string $name): array + { + $namespaceParts = \explode('::', $name, 2); - if (count($namespaceParts) === 2) { - return [ - $this->loaders[$namespaceParts[0]], - $namespaceParts[1], - ]; - } + if (count($namespaceParts) === 2) { + return [ + $this->loaders[$namespaceParts[0]], + $namespaceParts[1], + ]; + } - return [ - $this->loaders[''], - $name, - ]; - } + return [ + $this->loaders[''], + $name, + ]; + } } diff --git a/tests/common/Loaders.NamespaceLoader.phpt b/tests/common/Loaders.NamespaceLoader.phpt index 5327229511..018434a249 100644 --- a/tests/common/Loaders.NamespaceLoader.phpt +++ b/tests/common/Loaders.NamespaceLoader.phpt @@ -14,17 +14,17 @@ require __DIR__ . '/../bootstrap.php'; test('', function () { - $defaultLoader = new StringLoader(['main' => 'defaultcontent']); - $appLoader = new StringLoader(['main' => 'appcontent']); - $otherLoader = new StringLoader(['main' => 'othercontent']); - - $loader = new NamespaceLoader([ - '' => $defaultLoader, - 'app' => $appLoader, - 'other' => $otherLoader, - ]); - - Assert::same('defaultcontent', $loader->getContent('main')); - Assert::same('appcontent', $loader->getContent('app::main')); - Assert::same('othercontent', $loader->getContent('other::main')); + $defaultLoader = new StringLoader(['main' => 'defaultcontent']); + $appLoader = new StringLoader(['main' => 'appcontent']); + $otherLoader = new StringLoader(['main' => 'othercontent']); + + $loader = new NamespaceLoader([ + '' => $defaultLoader, + 'app' => $appLoader, + 'other' => $otherLoader, + ]); + + Assert::same('defaultcontent', $loader->getContent('main')); + Assert::same('appcontent', $loader->getContent('app::main')); + Assert::same('othercontent', $loader->getContent('other::main')); });