Conditions | 1 |
Paths | 1 |
Total Lines | 54 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php namespace Limoncello\Application\Packages\L10n; |
||
38 | public static function configureContainer(LimoncelloContainerInterface $container): void |
||
39 | { |
||
40 | $container[FormatterFactoryInterface::class] = function (PsrContainerInterface $container) { |
||
41 | $settingsProvider = $container->get(SettingsProviderInterface::class); |
||
42 | $settings = $settingsProvider->get(S::class); |
||
43 | |||
44 | $defaultLocale = $settings[S::KEY_DEFAULT_LOCALE]; |
||
45 | $storageData = $settings[S::KEY_LOCALES_DATA]; |
||
46 | |||
47 | $factory = new class ($defaultLocale, $storageData) implements FormatterFactoryInterface |
||
48 | { |
||
49 | /** |
||
50 | * @var string |
||
51 | */ |
||
52 | private $defaultLocale; |
||
53 | |||
54 | /** |
||
55 | * @var array |
||
56 | */ |
||
57 | private $storageData; |
||
58 | |||
59 | /** |
||
60 | * @param string $defaultLocale |
||
61 | * @param array $storageData |
||
62 | */ |
||
63 | public function __construct(string $defaultLocale, array $storageData) |
||
64 | { |
||
65 | $this->defaultLocale = $defaultLocale; |
||
66 | $this->storageData = $storageData; |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @inheritdoc |
||
71 | */ |
||
72 | public function createFormatter(string $namespace): FormatterInterface |
||
73 | { |
||
74 | return $this->createFormatterForLocale($namespace, $this->defaultLocale); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @inheritdoc |
||
79 | */ |
||
80 | public function createFormatterForLocale(string $namespace, string $locale): FormatterInterface |
||
81 | { |
||
82 | $translator = new Translator(new BundleStorage($this->storageData)); |
||
83 | $formatter = new Formatter($locale, $namespace, $translator); |
||
84 | |||
85 | return $formatter; |
||
86 | } |
||
87 | }; |
||
88 | |||
89 | return $factory; |
||
90 | }; |
||
91 | } |
||
92 | } |
||
93 |