From bfa81490c1085978f6431e06025e2794f7232768 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Fri, 3 May 2024 13:00:14 +0200 Subject: Rename HelpHelper to HelpHelperTrait. PHPCS prefers traits to be suffixed with "Trait", and I think I agree. --- Zotlabs/Lib/Traits/HelpHelper.php | 68 ---------------------------------- Zotlabs/Lib/Traits/HelpHelperTrait.php | 68 ++++++++++++++++++++++++++++++++++ Zotlabs/Module/Help.php | 2 +- Zotlabs/Widget/Helpindex.php | 2 +- 4 files changed, 70 insertions(+), 70 deletions(-) delete mode 100644 Zotlabs/Lib/Traits/HelpHelper.php create mode 100644 Zotlabs/Lib/Traits/HelpHelperTrait.php diff --git a/Zotlabs/Lib/Traits/HelpHelper.php b/Zotlabs/Lib/Traits/HelpHelper.php deleted file mode 100644 index f0dca35d0..000000000 --- a/Zotlabs/Lib/Traits/HelpHelper.php +++ /dev/null @@ -1,68 +0,0 @@ -getList(); - - if(array_key_exists(argv(1), $languages)) { - $lang = argv(1); - $from_url = true; - } else { - $lang = \App::$language; - if(! isset($lang)) - $lang = 'en'; - - $from_url = false; - } - - $this->lang = array('language' => $lang, 'from_url' => $from_url); - } - - /** - * Find the full path name of the file, given it's base path and - * the language of the request. - * - * @param string $base_path The path of the file to find, relative to the - * doc root path, and without the extension. - */ - private function find_help_file(string $base_path, string $lang): void { - - // Use local variable until we can use trait constants. - $valid_file_ext = ['md', 'bb', 'html']; - - $base_path = "doc/{$lang}/${base_path}"; - - foreach ($valid_file_ext as $ext) { - $path = "{$base_path}.{$ext}"; - if (file_exists($path)) { - $this->file_name = $path; - $this->file_type = $ext; - - break; - } - } - } -} diff --git a/Zotlabs/Lib/Traits/HelpHelperTrait.php b/Zotlabs/Lib/Traits/HelpHelperTrait.php new file mode 100644 index 000000000..b7711bbd5 --- /dev/null +++ b/Zotlabs/Lib/Traits/HelpHelperTrait.php @@ -0,0 +1,68 @@ +getList(); + + if(array_key_exists(argv(1), $languages)) { + $lang = argv(1); + $from_url = true; + } else { + $lang = \App::$language; + if(! isset($lang)) + $lang = 'en'; + + $from_url = false; + } + + $this->lang = array('language' => $lang, 'from_url' => $from_url); + } + + /** + * Find the full path name of the file, given it's base path and + * the language of the request. + * + * @param string $base_path The path of the file to find, relative to the + * doc root path, and without the extension. + */ + private function find_help_file(string $base_path, string $lang): void { + + // Use local variable until we can use trait constants. + $valid_file_ext = ['md', 'bb', 'html']; + + $base_path = "doc/{$lang}/${base_path}"; + + foreach ($valid_file_ext as $ext) { + $path = "{$base_path}.{$ext}"; + if (file_exists($path)) { + $this->file_name = $path; + $this->file_type = $ext; + + break; + } + } + } +} diff --git a/Zotlabs/Module/Help.php b/Zotlabs/Module/Help.php index 00946368f..5d52440a5 100644 --- a/Zotlabs/Module/Help.php +++ b/Zotlabs/Module/Help.php @@ -14,7 +14,7 @@ use Michelf\MarkdownExtra; */ class Help extends \Zotlabs\Web\Controller { - use \Zotlabs\Lib\Traits\HelpHelper; + use \Zotlabs\Lib\Traits\HelpHelperTrait; private string $heading_slug = ''; diff --git a/Zotlabs/Widget/Helpindex.php b/Zotlabs/Widget/Helpindex.php index 23261ca6f..5264e1947 100644 --- a/Zotlabs/Widget/Helpindex.php +++ b/Zotlabs/Widget/Helpindex.php @@ -12,7 +12,7 @@ namespace Zotlabs\Widget; class Helpindex { - use \Zotlabs\Lib\Traits\HelpHelper; + use \Zotlabs\Lib\Traits\HelpHelperTrait; private string $contents = ''; -- cgit v1.2.3