Skip to content

Commit b781afd

Browse files
committed
Cache configuration handler
1 parent 592220d commit b781afd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/ParsedownExtended.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class ParsedownExtended extends \ParsedownExtendedParentAlias
4242
/** @var array $configSchema Schema for validating configuration options */
4343
private array $configSchema;
4444

45+
/** @var object|null $configHandler Cached configuration handler */
46+
private $configHandler = null;
47+
4548
/** @var bool $legacyMode Flag indicating if legacy compatibility mode is enabled */
4649
private bool $legacyMode = false;
4750

@@ -3374,9 +3377,10 @@ public function getConfigSchema(): array
33743377
*/
33753378
public function config()
33763379
{
3377-
return new class ($this->configSchema, $this->config) {
3378-
private array $schema;
3379-
private $config;
3380+
if ($this->configHandler === null) {
3381+
$this->configHandler = new class ($this->configSchema, $this->config) {
3382+
private array $schema;
3383+
private $config;
33803384

33813385
/**
33823386
* Constructor to initialize configuration schema and reference configuration array.
@@ -3594,6 +3598,9 @@ protected function validateType($value, string $expectedType, ?array $schema = n
35943598
}
35953599
}
35963600
};
3601+
}
3602+
3603+
return $this->configHandler;
35973604
}
35983605

35993606

0 commit comments

Comments
 (0)