Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
oliwierptak committed Aug 4, 2023
1 parent 034a999 commit a59c7ad
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@
* Everon logger configuration file. Auto-generated.
*/

declare(strict_types = 1);
declare(strict_types=1);

namespace Everon\Shared\LoggerBasic\Configurator\Plugin;

use DateTime;
use DateTimeZone;
use Throwable;
use UnexpectedValueException;

use function array_filter;
use function array_key_exists;
use function array_keys;
use function array_replace_recursive;
use function in_array;
use function sort;

use const ARRAY_FILTER_USE_KEY;
use const SORT_STRING;

Expand Down Expand Up @@ -161,7 +164,7 @@ public function requireAll(): self

if (empty($errors) === false) {
throw new UnexpectedValueException(
implode("\n", $errors),
implode("\n", $errors)
);
}

Expand All @@ -179,6 +182,7 @@ public function fromArray(array $data): self
];



foreach ($metadata as $name => $mappedName) {
$meta = self::METADATA[$name];
$value = $data[$mappedName] ?? $this->$name ?? null;
Expand Down Expand Up @@ -300,6 +304,7 @@ public function toArray(): array
}



return $data;
}

Expand All @@ -316,9 +321,7 @@ protected function map(array $data, array $mappings): array

if (self::METADATA[$name]['type'] === 'popo') {
$popo = self::METADATA[$name]['default'];
$value = $this->$name !== null ? $this->$name->toMappedArray(...$mappings) : (new $popo)->toMappedArray(
...$mappings,
);
$value = $this->$name !== null ? $this->$name->toMappedArray(...$mappings) : (new $popo)->toMappedArray(...$mappings);
}

$key = $this->mapKeyName($mappings, $propertyMetadata['mappingPolicyValue']);
Expand Down Expand Up @@ -352,22 +355,22 @@ static function (string $key): string {
$mappingPolicy['snake-to-camel'] =
static function (string $key): string {
$stringTokens = explode('_', mb_strtolower($key));
$camelizedString = array_shift($stringTokens);
foreach ($stringTokens as $token) {
$camelizedString .= ucfirst($token);
}
$camelizedString = array_shift($stringTokens);
foreach ($stringTokens as $token) {
$camelizedString .= ucfirst($token);
}

return $camelizedString;
return $camelizedString;
};

$mappingPolicy['camel-to-snake'] =
static function (string $key): string {
$camelizedStringTokens = preg_split('/(?<=[^A-Z])(?=[A-Z])/', $key);
if ($camelizedStringTokens !== false && count($camelizedStringTokens) > 0) {
$key = mb_strtolower(implode('_', $camelizedStringTokens));
}
if ($camelizedStringTokens !== false && count($camelizedStringTokens) > 0) {
$key = mb_strtolower(implode('_', $camelizedStringTokens));
}

return $key;
return $key;
};

}
Expand Down Expand Up @@ -426,9 +429,7 @@ public function requirePluginClass(): string

public function setPluginClass(?string $pluginClass): self
{
$this->pluginClass = $pluginClass;
$this->updateMap['pluginClass'] = true;
return $this;
$this->pluginClass = $pluginClass; $this->updateMap['pluginClass'] = true; return $this;
}

/**
Expand Down Expand Up @@ -463,9 +464,7 @@ public function requirePluginFactoryClass(): string
*/
public function setPluginFactoryClass(?string $pluginFactoryClass): self
{
$this->pluginFactoryClass = $pluginFactoryClass;
$this->updateMap['pluginFactoryClass'] = true;
return $this;
$this->pluginFactoryClass = $pluginFactoryClass; $this->updateMap['pluginFactoryClass'] = true; return $this;
}

/**
Expand Down Expand Up @@ -500,9 +499,7 @@ public function requireShouldBubble(): bool
*/
public function setShouldBubble(bool $shouldBubble): self
{
$this->shouldBubble = $shouldBubble;
$this->updateMap['shouldBubble'] = true;
return $this;
$this->shouldBubble = $shouldBubble; $this->updateMap['shouldBubble'] = true; return $this;
}

/**
Expand Down Expand Up @@ -537,9 +534,7 @@ public function requireMessageType(): int
*/
public function setMessageType(?int $messageType): self
{
$this->messageType = $messageType;
$this->updateMap['messageType'] = true;
return $this;
$this->messageType = $messageType; $this->updateMap['messageType'] = true; return $this;
}

/**
Expand Down Expand Up @@ -574,8 +569,6 @@ public function requireExpandNewlines(): bool
*/
public function setExpandNewlines(bool $expandNewlines): self
{
$this->expandNewlines = $expandNewlines;
$this->updateMap['expandNewlines'] = true;
return $this;
$this->expandNewlines = $expandNewlines; $this->updateMap['expandNewlines'] = true; return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@
* Everon logger configuration file. Auto-generated.
*/

declare(strict_types = 1);
declare(strict_types=1);

namespace Everon\Shared\LoggerBasic\Configurator\Plugin;

use DateTime;
use DateTimeZone;
use Throwable;
use UnexpectedValueException;

use function array_filter;
use function array_key_exists;
use function array_keys;
use function array_replace_recursive;
use function in_array;
use function sort;

use const ARRAY_FILTER_USE_KEY;
use const SORT_STRING;

Expand Down Expand Up @@ -129,7 +132,7 @@ public function requireAll(): self

if (empty($errors) === false) {
throw new UnexpectedValueException(
implode("\n", $errors),
implode("\n", $errors)
);
}

Expand All @@ -145,6 +148,7 @@ public function fromArray(array $data): self
];



foreach ($metadata as $name => $mappedName) {
$meta = self::METADATA[$name];
$value = $data[$mappedName] ?? $this->$name ?? null;
Expand Down Expand Up @@ -264,6 +268,7 @@ public function toArray(): array
}



return $data;
}

Expand All @@ -280,9 +285,7 @@ protected function map(array $data, array $mappings): array

if (self::METADATA[$name]['type'] === 'popo') {
$popo = self::METADATA[$name]['default'];
$value = $this->$name !== null ? $this->$name->toMappedArray(...$mappings) : (new $popo)->toMappedArray(
...$mappings,
);
$value = $this->$name !== null ? $this->$name->toMappedArray(...$mappings) : (new $popo)->toMappedArray(...$mappings);
}

$key = $this->mapKeyName($mappings, $propertyMetadata['mappingPolicyValue']);
Expand Down Expand Up @@ -316,22 +319,22 @@ static function (string $key): string {
$mappingPolicy['snake-to-camel'] =
static function (string $key): string {
$stringTokens = explode('_', mb_strtolower($key));
$camelizedString = array_shift($stringTokens);
foreach ($stringTokens as $token) {
$camelizedString .= ucfirst($token);
}
$camelizedString = array_shift($stringTokens);
foreach ($stringTokens as $token) {
$camelizedString .= ucfirst($token);
}

return $camelizedString;
return $camelizedString;
};

$mappingPolicy['camel-to-snake'] =
static function (string $key): string {
$camelizedStringTokens = preg_split('/(?<=[^A-Z])(?=[A-Z])/', $key);
if ($camelizedStringTokens !== false && count($camelizedStringTokens) > 0) {
$key = mb_strtolower(implode('_', $camelizedStringTokens));
}
if ($camelizedStringTokens !== false && count($camelizedStringTokens) > 0) {
$key = mb_strtolower(implode('_', $camelizedStringTokens));
}

return $key;
return $key;
};

}
Expand Down Expand Up @@ -390,9 +393,7 @@ public function requirePluginClass(): string

public function setPluginClass(?string $pluginClass): self
{
$this->pluginClass = $pluginClass;
$this->updateMap['pluginClass'] = true;
return $this;
$this->pluginClass = $pluginClass; $this->updateMap['pluginClass'] = true; return $this;
}

/**
Expand Down Expand Up @@ -427,9 +428,7 @@ public function requirePluginFactoryClass(): string
*/
public function setPluginFactoryClass(?string $pluginFactoryClass): self
{
$this->pluginFactoryClass = $pluginFactoryClass;
$this->updateMap['pluginFactoryClass'] = true;
return $this;
$this->pluginFactoryClass = $pluginFactoryClass; $this->updateMap['pluginFactoryClass'] = true; return $this;
}

/**
Expand Down Expand Up @@ -464,8 +463,6 @@ public function requireShouldBubble(): bool
*/
public function setShouldBubble(bool $shouldBubble): self
{
$this->shouldBubble = $shouldBubble;
$this->updateMap['shouldBubble'] = true;
return $this;
$this->shouldBubble = $shouldBubble; $this->updateMap['shouldBubble'] = true; return $this;
}
}
Loading

0 comments on commit a59c7ad

Please sign in to comment.