@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | trait AnnotationTrait |
| 12 | 12 | { |
| 13 | - /** |
|
| 13 | +/** |
|
| 14 | 14 | * Get the metadata from a given class |
| 15 | 15 | * |
| 16 | 16 | * @param ReflectionClass|string $xClass |
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @return Metadata|null |
| 21 | 21 | */ |
| 22 | - public function getAttributes(ReflectionClass|string $xClass, |
|
| 23 | - array $aMethods = [], array $aProperties = []): ?Metadata |
|
| 24 | - { |
|
| 25 | - $xInputData = new InputData($xClass, $aMethods, $aProperties); |
|
| 26 | - $xMetadataReader = jaxon()->di()->getMetadataReader('annotations'); |
|
| 27 | - return $xMetadataReader->getAttributes($xInputData); |
|
| 28 | - } |
|
| 22 | +public function getAttributes(ReflectionClass|string $xClass, |
|
| 23 | +array $aMethods = [], array $aProperties = []): ?Metadata |
|
| 24 | +{ |
|
| 25 | +$xInputData = new InputData($xClass, $aMethods, $aProperties); |
|
| 26 | +$xMetadataReader = jaxon()->di()->getMetadataReader('annotations'); |
|
| 27 | +return $xMetadataReader->getAttributes($xInputData); |
|
| 28 | +} |
|
| 29 | 29 | } |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | class ConfigReader |
| 21 | 21 | { |
| 22 | - /** |
|
| 22 | +/** |
|
| 23 | 23 | * @param ConfigSetter $xConfigSetter |
| 24 | 24 | */ |
| 25 | - public function __construct(private ConfigSetter $xConfigSetter) |
|
| 26 | - {} |
|
| 25 | +public function __construct(private ConfigSetter $xConfigSetter) |
|
| 26 | +{} |
|
| 27 | 27 | |
| 28 | - /** |
|
| 28 | +/** |
|
| 29 | 29 | * Read options from a config file to an array |
| 30 | 30 | * |
| 31 | 31 | * @param string $sConfigFile The full path to the config file |
@@ -36,29 +36,29 @@ discard block |
||
| 36 | 36 | * @throws Exception\FileContent |
| 37 | 37 | * @throws Exception\YamlExtension |
| 38 | 38 | */ |
| 39 | - public function read(string $sConfigFile): array |
|
| 40 | - { |
|
| 41 | - if(!($sConfigFile = trim($sConfigFile))) |
|
| 42 | - { |
|
| 43 | - return []; |
|
| 44 | - } |
|
| 39 | +public function read(string $sConfigFile): array |
|
| 40 | +{ |
|
| 41 | +if(!($sConfigFile = trim($sConfigFile))) |
|
| 42 | +{ |
|
| 43 | +return []; |
|
| 44 | +} |
|
| 45 | 45 | |
| 46 | - $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION); |
|
| 47 | - switch($sExt) |
|
| 48 | - { |
|
| 49 | - case 'php': |
|
| 50 | - $aConfigOptions = Reader\PhpReader::read($sConfigFile); |
|
| 51 | - break; |
|
| 52 | - case 'yaml': |
|
| 53 | - case 'yml': |
|
| 54 | - $aConfigOptions = Reader\YamlReader::read($sConfigFile); |
|
| 55 | - break; |
|
| 56 | - case 'json': |
|
| 57 | - $aConfigOptions = Reader\JsonReader::read($sConfigFile); |
|
| 58 | - break; |
|
| 59 | - default: |
|
| 60 | - throw new Exception\FileExtension($sConfigFile); |
|
| 61 | - } |
|
| 46 | +$sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION); |
|
| 47 | +switch($sExt) |
|
| 48 | +{ |
|
| 49 | +case 'php': |
|
| 50 | +$aConfigOptions = Reader\PhpReader::read($sConfigFile); |
|
| 51 | +break; |
|
| 52 | +case 'yaml': |
|
| 53 | +case 'yml': |
|
| 54 | +$aConfigOptions = Reader\YamlReader::read($sConfigFile); |
|
| 55 | +break; |
|
| 56 | +case 'json': |
|
| 57 | +$aConfigOptions = Reader\JsonReader::read($sConfigFile); |
|
| 58 | +break; |
|
| 59 | +default: |
|
| 60 | +throw new Exception\FileExtension($sConfigFile); |
|
| 61 | +} |
|
| 62 | 62 | |
| 63 | 63 | return $aConfigOptions; |
| 64 | 64 | } |
@@ -20,50 +20,50 @@ |
||
| 20 | 20 | |
| 21 | 21 | class InputData |
| 22 | 22 | { |
| 23 | - /** |
|
| 23 | +/** |
|
| 24 | 24 | * @var ReflectionClass |
| 25 | 25 | */ |
| 26 | - private $xReflectionClass; |
|
| 26 | +private $xReflectionClass; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 28 | +/** |
|
| 29 | 29 | * @param ReflectionClass|string $xClass |
| 30 | 30 | * @param array $aMethods |
| 31 | 31 | * @param array $aProperties |
| 32 | 32 | */ |
| 33 | - public function __construct(ReflectionClass|string $xClass, |
|
| 34 | - private array $aMethods = [], private array $aProperties = []) |
|
| 35 | - { |
|
| 36 | - $this->xReflectionClass = is_string($xClass) ? |
|
| 37 | - new ReflectionClass($xClass) : $xClass; |
|
| 38 | - } |
|
| 33 | +public function __construct(ReflectionClass|string $xClass, |
|
| 34 | +private array $aMethods = [], private array $aProperties = []) |
|
| 35 | +{ |
|
| 36 | +$this->xReflectionClass = is_string($xClass) ? |
|
| 37 | +new ReflectionClass($xClass) : $xClass; |
|
| 38 | +} |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * Get the reflection class |
| 42 | 42 | * |
| 43 | 43 | * @return ReflectionClass |
| 44 | 44 | */ |
| 45 | - public function getReflectionClass(): ReflectionClass |
|
| 46 | - { |
|
| 47 | - return $this->xReflectionClass; |
|
| 48 | - } |
|
| 45 | +public function getReflectionClass(): ReflectionClass |
|
| 46 | +{ |
|
| 47 | +return $this->xReflectionClass; |
|
| 48 | +} |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | +/** |
|
| 51 | 51 | * The methods to check for metadata |
| 52 | 52 | * |
| 53 | 53 | * @return array |
| 54 | 54 | */ |
| 55 | - public function getMethods(): array |
|
| 56 | - { |
|
| 57 | - return $this->aMethods; |
|
| 58 | - } |
|
| 55 | +public function getMethods(): array |
|
| 56 | +{ |
|
| 57 | +return $this->aMethods; |
|
| 58 | +} |
|
| 59 | 59 | |
| 60 | - /** |
|
| 60 | +/** |
|
| 61 | 61 | * The properties to check for metadata |
| 62 | 62 | * |
| 63 | 63 | * @return array |
| 64 | 64 | */ |
| 65 | - public function getProperties(): array |
|
| 66 | - { |
|
| 67 | - return $this->aProperties; |
|
| 68 | - } |
|
| 65 | +public function getProperties(): array |
|
| 66 | +{ |
|
| 67 | +return $this->aProperties; |
|
| 68 | +} |
|
| 69 | 69 | } |
@@ -16,42 +16,42 @@ |
||
| 16 | 16 | |
| 17 | 17 | class ExcludeData extends AbstractData |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @var bool |
| 21 | 21 | */ |
| 22 | - private bool $bValue = true; |
|
| 22 | +private bool $bValue = true; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * @return string |
| 26 | 26 | */ |
| 27 | - public function getName(): string |
|
| 28 | - { |
|
| 29 | - return 'protected'; |
|
| 30 | - } |
|
| 27 | +public function getName(): string |
|
| 28 | +{ |
|
| 29 | +return 'protected'; |
|
| 30 | +} |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | +/** |
|
| 33 | 33 | * @return mixed |
| 34 | 34 | */ |
| 35 | - public function getValue(): mixed |
|
| 36 | - { |
|
| 37 | - return $this->bValue; |
|
| 38 | - } |
|
| 35 | +public function getValue(): mixed |
|
| 36 | +{ |
|
| 37 | +return $this->bValue; |
|
| 38 | +} |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * @param bool $bValue |
| 42 | 42 | * |
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | - public function setValue(bool $bValue): void |
|
| 46 | - { |
|
| 47 | - $this->bValue = $bValue; |
|
| 48 | - } |
|
| 45 | +public function setValue(bool $bValue): void |
|
| 46 | +{ |
|
| 47 | +$this->bValue = $bValue; |
|
| 48 | +} |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | +/** |
|
| 51 | 51 | * @inheritDoc |
| 52 | 52 | */ |
| 53 | - public function encode(string $sVarName): array |
|
| 54 | - { |
|
| 55 | - return ["{$sVarName}->setValue(" . ($this->bValue ? 'true' : 'false') . ");"]; |
|
| 56 | - } |
|
| 53 | +public function encode(string $sVarName): array |
|
| 54 | +{ |
|
| 55 | +return ["{$sVarName}->setValue(" . ($this->bValue ? 'true' : 'false') . ");"]; |
|
| 56 | +} |
|
| 57 | 57 | } |
@@ -20,61 +20,61 @@ |
||
| 20 | 20 | |
| 21 | 21 | class UploadData extends AbstractData |
| 22 | 22 | { |
| 23 | - /** |
|
| 23 | +/** |
|
| 24 | 24 | * The id of the upload field |
| 25 | 25 | * |
| 26 | 26 | * @var string |
| 27 | 27 | */ |
| 28 | - protected $sField = ''; |
|
| 28 | +protected $sField = ''; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 30 | +/** |
|
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | - public function getName(): string |
|
| 34 | - { |
|
| 35 | - return 'upload'; |
|
| 36 | - } |
|
| 33 | +public function getName(): string |
|
| 34 | +{ |
|
| 35 | +return 'upload'; |
|
| 36 | +} |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | +/** |
|
| 39 | 39 | * @return mixed |
| 40 | 40 | */ |
| 41 | - public function getValue(): mixed |
|
| 42 | - { |
|
| 43 | - // The field id is surrounded with simple quotes. |
|
| 44 | - return "'{$this->sField}'"; |
|
| 45 | - } |
|
| 41 | +public function getValue(): mixed |
|
| 42 | +{ |
|
| 43 | +// The field id is surrounded with simple quotes. |
|
| 44 | +return "'{$this->sField}'"; |
|
| 45 | +} |
|
| 46 | 46 | |
| 47 | - /** |
|
| 47 | +/** |
|
| 48 | 48 | * @param string $sField |
| 49 | 49 | * |
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | - protected function validateField(string $sField): void |
|
| 53 | - { |
|
| 54 | - if(preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sField) > 0) |
|
| 55 | - { |
|
| 56 | - return; |
|
| 57 | - } |
|
| 58 | - throw new SetupException("$sField is not a valid \"field\" value for upload"); |
|
| 59 | - } |
|
| 52 | +protected function validateField(string $sField): void |
|
| 53 | +{ |
|
| 54 | +if(preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sField) > 0) |
|
| 55 | +{ |
|
| 56 | +return; |
|
| 57 | +} |
|
| 58 | +throw new SetupException("$sField is not a valid \"field\" value for upload"); |
|
| 59 | +} |
|
| 60 | 60 | |
| 61 | - /** |
|
| 61 | +/** |
|
| 62 | 62 | * @param string $sField |
| 63 | 63 | * |
| 64 | 64 | * @return void |
| 65 | 65 | */ |
| 66 | - public function setValue(string $sField): void |
|
| 67 | - { |
|
| 68 | - $this->validateField($sField); |
|
| 66 | +public function setValue(string $sField): void |
|
| 67 | +{ |
|
| 68 | +$this->validateField($sField); |
|
| 69 | 69 | |
| 70 | - $this->sField = $sField; |
|
| 71 | - } |
|
| 70 | +$this->sField = $sField; |
|
| 71 | +} |
|
| 72 | 72 | |
| 73 | - /** |
|
| 73 | +/** |
|
| 74 | 74 | * @inheritDoc |
| 75 | 75 | */ |
| 76 | - public function encode(string $sVarName): array |
|
| 77 | - { |
|
| 78 | - return ["{$sVarName}->setValue('{$this->sField}');"]; |
|
| 79 | - } |
|
| 76 | +public function encode(string $sVarName): array |
|
| 77 | +{ |
|
| 78 | +return ["{$sVarName}->setValue('{$this->sField}');"]; |
|
| 79 | +} |
|
| 80 | 80 | } |
@@ -21,81 +21,81 @@ |
||
| 21 | 21 | |
| 22 | 22 | class ContainerData extends AbstractData |
| 23 | 23 | { |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * The properties to get from the container |
| 26 | 26 | * |
| 27 | 27 | * @var string |
| 28 | 28 | */ |
| 29 | - protected $aProperties = []; |
|
| 29 | +protected $aProperties = []; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * @return string |
| 33 | 33 | */ |
| 34 | - public function getName(): string |
|
| 35 | - { |
|
| 36 | - return '__di'; |
|
| 37 | - } |
|
| 34 | +public function getName(): string |
|
| 35 | +{ |
|
| 36 | +return '__di'; |
|
| 37 | +} |
|
| 38 | 38 | |
| 39 | - /** |
|
| 39 | +/** |
|
| 40 | 40 | * @return mixed |
| 41 | 41 | */ |
| 42 | - public function getValue(): mixed |
|
| 43 | - { |
|
| 44 | - return $this->aProperties; |
|
| 45 | - } |
|
| 42 | +public function getValue(): mixed |
|
| 43 | +{ |
|
| 44 | +return $this->aProperties; |
|
| 45 | +} |
|
| 46 | 46 | |
| 47 | - /** |
|
| 47 | +/** |
|
| 48 | 48 | * @param string $sAttr |
| 49 | 49 | * |
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | - protected function validateAttr(string $sAttr): void |
|
| 53 | - { |
|
| 54 | - if(preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sAttr) > 0) |
|
| 55 | - { |
|
| 56 | - return; |
|
| 57 | - } |
|
| 58 | - throw new SetupException("$sAttr is not a valid \"attr\" value for di"); |
|
| 59 | - } |
|
| 52 | +protected function validateAttr(string $sAttr): void |
|
| 53 | +{ |
|
| 54 | +if(preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sAttr) > 0) |
|
| 55 | +{ |
|
| 56 | +return; |
|
| 57 | +} |
|
| 58 | +throw new SetupException("$sAttr is not a valid \"attr\" value for di"); |
|
| 59 | +} |
|
| 60 | 60 | |
| 61 | - /** |
|
| 61 | +/** |
|
| 62 | 62 | * @param string $sClass |
| 63 | 63 | * |
| 64 | 64 | * @return void |
| 65 | 65 | */ |
| 66 | - protected function validateClass(string $sClass): void |
|
| 67 | - { |
|
| 68 | - if(preg_match('/^(\\\)?([a-zA-Z][a-zA-Z0-9_]*)(\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sClass) > 0) |
|
| 69 | - { |
|
| 70 | - return; |
|
| 71 | - } |
|
| 72 | - throw new SetupException("$sClass is not a valid \"class\" value for di"); |
|
| 73 | - } |
|
| 66 | +protected function validateClass(string $sClass): void |
|
| 67 | +{ |
|
| 68 | +if(preg_match('/^(\\\)?([a-zA-Z][a-zA-Z0-9_]*)(\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sClass) > 0) |
|
| 69 | +{ |
|
| 70 | +return; |
|
| 71 | +} |
|
| 72 | +throw new SetupException("$sClass is not a valid \"class\" value for di"); |
|
| 73 | +} |
|
| 74 | 74 | |
| 75 | - /** |
|
| 75 | +/** |
|
| 76 | 76 | * @param string $sAttr |
| 77 | 77 | * @param string $sClass |
| 78 | 78 | * |
| 79 | 79 | * @return void |
| 80 | 80 | */ |
| 81 | - public function addValue(string $sAttr, string $sClass): void |
|
| 82 | - { |
|
| 83 | - $this->validateAttr($sAttr); |
|
| 84 | - $this->validateClass($sClass); |
|
| 81 | +public function addValue(string $sAttr, string $sClass): void |
|
| 82 | +{ |
|
| 83 | +$this->validateAttr($sAttr); |
|
| 84 | +$this->validateClass($sClass); |
|
| 85 | 85 | |
| 86 | - $this->aProperties[$sAttr] = $sClass; |
|
| 87 | - } |
|
| 86 | +$this->aProperties[$sAttr] = $sClass; |
|
| 87 | +} |
|
| 88 | 88 | |
| 89 | - /** |
|
| 89 | +/** |
|
| 90 | 90 | * @inheritDoc |
| 91 | 91 | */ |
| 92 | - public function encode(string $sVarName): array |
|
| 93 | - { |
|
| 94 | - $aCalls = []; |
|
| 95 | - foreach($this->aProperties as $sAttr => $sClass) |
|
| 96 | - { |
|
| 97 | - $aCalls[] = "{$sVarName}->addValue('$sAttr', '" . addslashes($sClass) . "');"; |
|
| 98 | - } |
|
| 99 | - return $aCalls; |
|
| 100 | - } |
|
| 92 | +public function encode(string $sVarName): array |
|
| 93 | +{ |
|
| 94 | +$aCalls = []; |
|
| 95 | +foreach($this->aProperties as $sAttr => $sClass) |
|
| 96 | +{ |
|
| 97 | +$aCalls[] = "{$sVarName}->addValue('$sAttr', '" . addslashes($sClass) . "');"; |
|
| 98 | +} |
|
| 99 | +return $aCalls; |
|
| 100 | +} |
|
| 101 | 101 | } |
@@ -28,60 +28,60 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | class MetadataCache |
| 30 | 30 | { |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * @param string $sCacheDir |
| 33 | 33 | */ |
| 34 | - public function __construct(private string $sCacheDir) |
|
| 35 | - {} |
|
| 34 | +public function __construct(private string $sCacheDir) |
|
| 35 | +{} |
|
| 36 | 36 | |
| 37 | - /** |
|
| 37 | +/** |
|
| 38 | 38 | * @param string $sClass |
| 39 | 39 | * |
| 40 | 40 | * @return string |
| 41 | 41 | */ |
| 42 | - private function filepath(string $sClass): string |
|
| 43 | - { |
|
| 44 | - $sFilename = trim(str_replace(['\\', '.'], DIRECTORY_SEPARATOR, |
|
| 45 | - strtolower($sClass)), DIRECTORY_SEPARATOR); |
|
| 46 | - return rtrim($this->sCacheDir, "/\\") . DIRECTORY_SEPARATOR . |
|
| 47 | - "metadata" . DIRECTORY_SEPARATOR . "{$sFilename}.php"; |
|
| 48 | - } |
|
| 42 | +private function filepath(string $sClass): string |
|
| 43 | +{ |
|
| 44 | +$sFilename = trim(str_replace(['\\', '.'], DIRECTORY_SEPARATOR, |
|
| 45 | +strtolower($sClass)), DIRECTORY_SEPARATOR); |
|
| 46 | +return rtrim($this->sCacheDir, "/\\") . DIRECTORY_SEPARATOR . |
|
| 47 | +"metadata" . DIRECTORY_SEPARATOR . "{$sFilename}.php"; |
|
| 48 | +} |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | +/** |
|
| 51 | 51 | * Generate the PHP code to create a metadata object. |
| 52 | 52 | * |
| 53 | 53 | * @return array |
| 54 | 54 | */ |
| 55 | - private function encode(Metadata $xMetadata): array |
|
| 55 | +private function encode(Metadata $xMetadata): array |
|
| 56 | +{ |
|
| 57 | +$sMetadataVar = '$xMetadata'; |
|
| 58 | +$sDataVar = '$xData'; |
|
| 59 | +$aCalls = ["$sMetadataVar = new " . Metadata::class . '();']; |
|
| 60 | +foreach($xMetadata->getAttributes() as $sType => $aValues) |
|
| 61 | +{ |
|
| 62 | +foreach($aValues as $sMethod => $xData) |
|
| 63 | +{ |
|
| 64 | + $aCalls[] = "$sDataVar = {$sMetadataVar}->{$sType}('{$sMethod}');"; |
|
| 65 | + foreach($xData->encode($sDataVar) as $sCall) |
|
| 56 | 66 | { |
| 57 | - $sMetadataVar = '$xMetadata'; |
|
| 58 | - $sDataVar = '$xData'; |
|
| 59 | - $aCalls = ["$sMetadataVar = new " . Metadata::class . '();']; |
|
| 60 | - foreach($xMetadata->getAttributes() as $sType => $aValues) |
|
| 61 | - { |
|
| 62 | - foreach($aValues as $sMethod => $xData) |
|
| 63 | - { |
|
| 64 | - $aCalls[] = "$sDataVar = {$sMetadataVar}->{$sType}('{$sMethod}');"; |
|
| 65 | - foreach($xData->encode($sDataVar) as $sCall) |
|
| 66 | - { |
|
| 67 | - $aCalls[] = $sCall; |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - $aCalls[] = "return $sMetadataVar;"; |
|
| 72 | - return $aCalls; |
|
| 67 | + $aCalls[] = $sCall; |
|
| 73 | 68 | } |
| 69 | +} |
|
| 70 | +} |
|
| 71 | +$aCalls[] = "return $sMetadataVar;"; |
|
| 72 | +return $aCalls; |
|
| 73 | +} |
|
| 74 | 74 | |
| 75 | - /** |
|
| 75 | +/** |
|
| 76 | 76 | * @param string $sClass |
| 77 | 77 | * @param Metadata $xMetadata |
| 78 | 78 | * |
| 79 | 79 | * @return void |
| 80 | 80 | */ |
| 81 | - public function save(string $sClass, Metadata $xMetadata): void |
|
| 82 | - { |
|
| 83 | - $sDataCode = implode("\n ", $this->encode($xMetadata)); |
|
| 84 | - $sPhpCode = <<<CODE |
|
| 81 | +public function save(string $sClass, Metadata $xMetadata): void |
|
| 82 | +{ |
|
| 83 | +$sDataCode = implode("\n ", $this->encode($xMetadata)); |
|
| 84 | +$sPhpCode = <<<CODE |
|
| 85 | 85 | <?php |
| 86 | 86 | |
| 87 | 87 | return function() { |
@@ -89,21 +89,21 @@ discard block |
||
| 89 | 89 | }; |
| 90 | 90 | |
| 91 | 91 | CODE; |
| 92 | - // Recursively create the directories. |
|
| 93 | - $sPath = $this->filepath($sClass); |
|
| 94 | - @mkdir(dirname($sPath), 0755, true); |
|
| 95 | - file_put_contents($sPath, $sPhpCode); |
|
| 96 | - } |
|
| 92 | +// Recursively create the directories. |
|
| 93 | +$sPath = $this->filepath($sClass); |
|
| 94 | +@mkdir(dirname($sPath), 0755, true); |
|
| 95 | +file_put_contents($sPath, $sPhpCode); |
|
| 96 | +} |
|
| 97 | 97 | |
| 98 | - /** |
|
| 98 | +/** |
|
| 99 | 99 | * @param string $sClass |
| 100 | 100 | * |
| 101 | 101 | * @return Metadata|null |
| 102 | 102 | */ |
| 103 | - public function read(string $sClass): ?Metadata |
|
| 104 | - { |
|
| 105 | - $sPath = $this->filepath($sClass); |
|
| 106 | - $fCreator = file_exists($sPath) ? require $sPath : null; |
|
| 107 | - return $fCreator instanceof Closure ? $fCreator() : null; |
|
| 108 | - } |
|
| 103 | +public function read(string $sClass): ?Metadata |
|
| 104 | +{ |
|
| 105 | +$sPath = $this->filepath($sClass); |
|
| 106 | +$fCreator = file_exists($sPath) ? require $sPath : null; |
|
| 107 | +return $fCreator instanceof Closure ? $fCreator() : null; |
|
| 108 | +} |
|
| 109 | 109 | } |
@@ -20,45 +20,45 @@ |
||
| 20 | 20 | |
| 21 | 21 | interface UploadHandlerInterface |
| 22 | 22 | { |
| 23 | - /** |
|
| 23 | +/** |
|
| 24 | 24 | * Set the uploaded file name sanitizer |
| 25 | 25 | * |
| 26 | 26 | * @param Closure $cSanitizer The closure |
| 27 | 27 | * |
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | - public function sanitizer(Closure $cSanitizer); |
|
| 30 | +public function sanitizer(Closure $cSanitizer); |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | +/** |
|
| 33 | 33 | * Get the uploaded files |
| 34 | 34 | * |
| 35 | 35 | * @return FileInterface[] |
| 36 | 36 | */ |
| 37 | - public function files(): array; |
|
| 37 | +public function files(): array; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 39 | +/** |
|
| 40 | 40 | * Check if the current request contains uploaded files |
| 41 | 41 | * |
| 42 | 42 | * @param ServerRequestInterface $xRequest |
| 43 | 43 | * |
| 44 | 44 | * @return bool |
| 45 | 45 | */ |
| 46 | - public function canProcessRequest(ServerRequestInterface $xRequest): bool; |
|
| 46 | +public function canProcessRequest(ServerRequestInterface $xRequest): bool; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 48 | +/** |
|
| 49 | 49 | * Process the uploaded files in the HTTP request |
| 50 | 50 | * |
| 51 | 51 | * @param ServerRequestInterface $xRequest |
| 52 | 52 | * |
| 53 | 53 | * @return bool |
| 54 | 54 | */ |
| 55 | - public function processRequest(ServerRequestInterface $xRequest): bool; |
|
| 55 | +public function processRequest(ServerRequestInterface $xRequest): bool; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 57 | +/** |
|
| 58 | 58 | * @param string $sStorage |
| 59 | 59 | * @param Closure $cFactory |
| 60 | 60 | * |
| 61 | 61 | * @return void |
| 62 | 62 | */ |
| 63 | - public function registerStorageAdapter(string $sStorage, Closure $cFactory); |
|
| 63 | +public function registerStorageAdapter(string $sStorage, Closure $cFactory); |
|
| 64 | 64 | } |
@@ -16,23 +16,23 @@ |
||
| 16 | 16 | |
| 17 | 17 | class Jaxon |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @const string |
| 21 | 21 | */ |
| 22 | - public const VERSION = 'Jaxon 5.x'; |
|
| 22 | +public const VERSION = 'Jaxon 5.x'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * @const string |
| 26 | 26 | */ |
| 27 | - public const CALLABLE_CLASS = 'CallableClass'; |
|
| 27 | +public const CALLABLE_CLASS = 'CallableClass'; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | +/** |
|
| 30 | 30 | * @const string |
| 31 | 31 | */ |
| 32 | - public const CALLABLE_DIR = 'CallableDir'; |
|
| 32 | +public const CALLABLE_DIR = 'CallableDir'; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 34 | +/** |
|
| 35 | 35 | * @const string |
| 36 | 36 | */ |
| 37 | - public const CALLABLE_FUNCTION = 'CallableFunction'; |
|
| 37 | +public const CALLABLE_FUNCTION = 'CallableFunction'; |
|
| 38 | 38 | } |