| Conditions | 3 |
| Paths | 1 |
| Total Lines | 23 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public function __construct() |
||
| 18 | { |
||
| 19 | $this->factoryMap['dummy'] = function () |
||
| 20 | { |
||
| 21 | return new DummyStorageDriver(); |
||
| 22 | }; |
||
| 23 | |||
| 24 | $this->factoryMap['path'] = function(VaultConfiguration $vaultConfiguration) |
||
| 25 | { |
||
| 26 | $path = $vaultConfiguration->getSetting('path'); |
||
| 27 | $path = $this->expandTildePath($path); |
||
| 28 | |||
| 29 | if (!is_dir($path) || !is_writable($path)) |
||
| 30 | { |
||
| 31 | throw new ConfigurationException(sprintf('Path "%s" does not exist or is not writable.', $path)); |
||
| 32 | } |
||
| 33 | |||
| 34 | $adapter = new Local($path); |
||
| 35 | $filesystem = new Filesystem($adapter); |
||
| 36 | |||
| 37 | return new FlysystemStorageDriver($filesystem); |
||
| 38 | }; |
||
| 39 | } |
||
| 40 | |||
| 53 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.