Skip to content

Commit

Permalink
feat(serializers): update all serializers #199
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Aug 1, 2021
1 parent 148e702 commit 8026a9b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/flextype/Support/Serializers/Frontmatter.php
Expand Up @@ -35,10 +35,10 @@ public function encode($input): string
if (isset($input['content'])) {
$content = $input['content'];
$input = arrays($input)->delete('content')->toArray();
$matter = flextype('serializers')->yaml()->encode($input);
$matter = serializers()->yaml()->encode($input);
} else {
$content = '';
$matter = flextype('serializers')->yaml()->encode($input);
$matter = serializers()->yaml()->encode($input);
}

return '---' . "\n" .
Expand Down Expand Up @@ -71,18 +71,18 @@ public function decode(string $input, bool $cache = true)
return ['content' => strings($input)->trim()->toString()];
}

return flextype('serializers')->yaml()->decode(strings($parts[1])->trim()->toString(), false) + ['content' => strings(implode(PHP_EOL . '---' . PHP_EOL, array_slice($parts, 2)))->trim()->toString()];
return serializers()->yaml()->decode(strings($parts[1])->trim()->toString(), false) + ['content' => strings(implode(PHP_EOL . '---' . PHP_EOL, array_slice($parts, 2)))->trim()->toString()];
};

if ($cache === true && flextype('registry')->get('flextype.settings.cache.enabled') === true) {
if ($cache === true && registry()->get('flextype.settings.cache.enabled') === true) {
$key = $this->getCacheID($input);

if ($dataFromCache = flextype('cache')->get($key)) {
if ($dataFromCache = cache()->get($key)) {
return $dataFromCache;
}

$data = $decode($input);
flextype('cache')->set($key, $data);
cache()->set($key, $data);

return $data;
}
Expand Down
6 changes: 3 additions & 3 deletions src/flextype/Support/Serializers/Json.php
Expand Up @@ -80,15 +80,15 @@ public function decode(string $input, bool $cache = true, bool $assoc = true, in
return $value;
};

if ($cache === true && flextype('registry')->get('flextype.settings.cache.enabled') === true) {
if ($cache === true && registry()->get('flextype.settings.cache.enabled') === true) {
$key = $this->getCacheID($input);

if ($dataFromCache = flextype('cache')->get($key)) {
if ($dataFromCache = cache()->get($key)) {
return $dataFromCache;
}

$data = $decode($input, $assoc, $depth, $flags);
flextype('cache')->set($key, $data);
cache()->set($key, $data);

return $data;
}
Expand Down
6 changes: 3 additions & 3 deletions src/flextype/Support/Serializers/Yaml.php
Expand Up @@ -113,15 +113,15 @@ public function decode(string $input, bool $cache = true, int $flags = 0)
}
};

if ($cache === true && flextype('registry')->get('flextype.settings.cache.enabled') === true) {
if ($cache === true && registry()->get('flextype.settings.cache.enabled') === true) {
$key = $this->getCacheID($input);

if ($dataFromCache = flextype('cache')->get($key)) {
if ($dataFromCache = cache()->get($key)) {
return $dataFromCache;
}

$data = $decode($input, $flags);
flextype('cache')->set($key, $data);
cache()->set($key, $data);

return $data;
}
Expand Down

0 comments on commit 8026a9b

Please sign in to comment.