From 695c488b9b9a25bc4477a3e2dc04e4b6ae1220cd Mon Sep 17 00:00:00 2001 From: Awilum Date: Wed, 2 Dec 2020 13:57:13 +0300 Subject: [PATCH] refactor(core): code formating and refactoring --- src/flextype/Foundation/Entries/Fields/IdField.php | 2 +- src/flextype/Foundation/Entries/Fields/SlugField.php | 2 +- src/flextype/Support/Parsers/Markdown.php | 2 +- src/flextype/Support/Parsers/Shortcode.php | 2 +- src/flextype/Support/Serializers/Frontmatter.php | 8 ++++---- src/flextype/Support/Serializers/Json.php | 2 +- src/flextype/Support/Serializers/Yaml.php | 2 +- src/flextype/dependencies.php | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/flextype/Foundation/Entries/Fields/IdField.php b/src/flextype/Foundation/Entries/Fields/IdField.php index 48aafd05..8598e73d 100644 --- a/src/flextype/Foundation/Entries/Fields/IdField.php +++ b/src/flextype/Foundation/Entries/Fields/IdField.php @@ -15,6 +15,6 @@ if (flextype('registry')->get('flextype.settings.entries.fields.id.enabled')) { return; } - flextype('entries')->setStorage('fetch.data.id', (string) Strings::create(flextype('entries')->getStorage('fetch.id'))->trimSlashes()); + flextype('entries')->setStorage('fetch.data.id', (string) strings(flextype('entries')->getStorage('fetch.id'))->trimSlashes()); }); } diff --git a/src/flextype/Foundation/Entries/Fields/SlugField.php b/src/flextype/Foundation/Entries/Fields/SlugField.php index 5c4a7942..e8bf5697 100644 --- a/src/flextype/Foundation/Entries/Fields/SlugField.php +++ b/src/flextype/Foundation/Entries/Fields/SlugField.php @@ -15,7 +15,7 @@ if (flextype('registry')->get('flextype.settings.entries.fields.slug.enabled')) return; } - $parts = Strings::create(flextype('entries')->getStorage('fetch.id'))->trimSlashes()->segments(); + $parts = strings(flextype('entries')->getStorage('fetch.id'))->trimSlashes()->segments(); flextype('entries')->setStorage('fetch.data.slug', (string) end($parts)); }); } diff --git a/src/flextype/Support/Parsers/Markdown.php b/src/flextype/Support/Parsers/Markdown.php index 63a50c60..f7c764fa 100644 --- a/src/flextype/Support/Parsers/Markdown.php +++ b/src/flextype/Support/Parsers/Markdown.php @@ -76,6 +76,6 @@ class Markdown public function getCacheID($input): string { - return Strings::create('markdown' . $input)->hash()->toString(); + return strings('markdown' . $input)->hash()->toString(); } } diff --git a/src/flextype/Support/Parsers/Shortcode.php b/src/flextype/Support/Parsers/Shortcode.php index 49530ef7..149f0ced 100644 --- a/src/flextype/Support/Parsers/Shortcode.php +++ b/src/flextype/Support/Parsers/Shortcode.php @@ -115,6 +115,6 @@ class Shortcode */ public function getCacheID(string $input): string { - return Strings::create('shortcode' . $input)->hash()->toString(); + return strings('shortcode' . $input)->hash()->toString(); } } diff --git a/src/flextype/Support/Serializers/Frontmatter.php b/src/flextype/Support/Serializers/Frontmatter.php index 3ad3dd83..8cb55789 100644 --- a/src/flextype/Support/Serializers/Frontmatter.php +++ b/src/flextype/Support/Serializers/Frontmatter.php @@ -94,17 +94,17 @@ class Frontmatter $input = (string) preg_replace("/(\r\n|\r)/", "\n", $input); // Parse Frontmatter and Body - $parts = preg_split('/^[\s\r\n]?---[\s\r\n]?$/sm', PHP_EOL . Strings::create($input)->trimLeft()->toString()); + $parts = preg_split('/^[\s\r\n]?---[\s\r\n]?$/sm', PHP_EOL . strings($input)->trimLeft()->toString()); if (count($parts) < 3) { - return ['content' => Strings::create($input)->trim()->toString()]; + return ['content' => strings($input)->trim()->toString()]; } - return flextype('yaml')->decode(Strings::create($parts[1])->trim()->toString(), false) + ['content' => Strings::create(implode(PHP_EOL . '---' . PHP_EOL, array_slice($parts, 2)))->trim()->toString()]; + return flextype('yaml')->decode(strings($parts[1])->trim()->toString(), false) + ['content' => strings(implode(PHP_EOL . '---' . PHP_EOL, array_slice($parts, 2)))->trim()->toString()]; } public function getCacheID($input): string { - return Strings::create('frontmatter' . $input)->hash()->toString(); + return strings('frontmatter' . $input)->hash()->toString(); } } diff --git a/src/flextype/Support/Serializers/Json.php b/src/flextype/Support/Serializers/Json.php index 9d54300c..fa7ff854 100644 --- a/src/flextype/Support/Serializers/Json.php +++ b/src/flextype/Support/Serializers/Json.php @@ -110,6 +110,6 @@ class Json public function getCacheID($input): string { - return Strings::create('json' . $input)->hash()->toString(); + return strings('json' . $input)->hash()->toString(); } } diff --git a/src/flextype/Support/Serializers/Yaml.php b/src/flextype/Support/Serializers/Yaml.php index 0fff3d5d..f118bd24 100644 --- a/src/flextype/Support/Serializers/Yaml.php +++ b/src/flextype/Support/Serializers/Yaml.php @@ -143,6 +143,6 @@ class Yaml public function getCacheID($input): string { - return Strings::create('yaml' . $input)->hash()->toString(); + return strings('yaml' . $input)->hash()->toString(); } } diff --git a/src/flextype/dependencies.php b/src/flextype/dependencies.php index 14d2267c..d74669c0 100644 --- a/src/flextype/dependencies.php +++ b/src/flextype/dependencies.php @@ -125,7 +125,7 @@ flextype()->container()['cache'] = static function () { if ($key === 'path' && in_array($driver_name, ['files', 'sqlite', 'leveldb'])) { $config['path'] = ! empty($value) ? PATH['tmp'] . '/' . $value : sys_get_temp_dir(); } else { - $config[Strings::create($key)->camel()->toString()] = $value; + $config[strings($key)->camel()->toString()] = $value; } }