ModuleConfig::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 73
Code Lines 50

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 73
rs 9.0675
cc 1
eloc 50
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Lichtenwallner  (https://lichtenwallner.at)
4
 *
5
 * @see https://github.com/jolicht/markdown-cms for the canonical source repository
6
 * @license https://github.com/jolicht/markdown-cms/blob/master/LICENSE MIT
7
 * @copyright Copyright (c) Johannes Lichtenwallner
8
 */
9
declare(strict_types = 1);
10
namespace Jolicht\MarkdownCms;
11
12
use Jolicht\MarkdownCms\ContentType\PageCreator;
13
use Jolicht\MarkdownCms\ContentType\BlogEntryCreator;
14
use Jolicht\MarkdownCms\Parser\ParseContentExecutor;
15
use Jolicht\MarkdownCms\Parser\ParseContentExecutorFactory;
16
use Jolicht\MarkdownCms\Parser\Observer\SaveContentConfigObserver;
17
use Jolicht\MarkdownCms\Action\SingleBlogEntryAction;
18
use Jolicht\MarkdownCms\Action\BlogOverviewAction;
19
use Jolicht\MarkdownCms\Parser\Observer\SitemapObserver;
20
use Jolicht\MarkdownCms\Action\TagArchiveAction;
21
22
/**
23
 * Configuration provider for module Jolicht\MarkdownCms
24
 */
25
class ModuleConfig
26
{
27
    /**
28
     * Get module config
29
     */
30
    public function __invoke()
31
    {
32
        return [
33
            'markdown_cms' => [
34
                'options' => [
35
                    'content_dir' => 'data/content',
36
                    'base_url' => 'http://replace.it',
37
                    'images_base_url' => 'http://replace.it/img',
38
                    'content_config_path' => 'config/autoload/markdown-cms.content.global.php',
39
                    'sitemap_path' => 'public/sitemap.xml',
40
                    'content_type_default' => 'blogEntry',
41
                    'parse_content_executor' => [
42
                        'observers' => [
43
                            'save_content_config' => SaveContentConfigObserver::class,
44
                            'sitemap' => SitemapObserver::class,
45
                        ]
46
                    ],
47
                    'url_translation' => [
48
                        // e.g.: 'http://devlopment.url' => 'https://production.url'
49
                    ],
50
                    'content_types' => [
51
                        'page' => [
52
                            'creator' => PageCreator::class,
53
                            'default_template' => 'app::page.twig'
54
                        ],
55
                        'blogEntry' => [
56
                            'creator' => BlogEntryCreator::class,
57
                            'default_template' => 'app::blog-entry.twig'
58
                        ]
59
                    ]
60
                ]
61
            ],
62
            'dependencies' => [
63
                'factories' => [
64
                    ParseContentExecutor::class => ParseContentExecutorFactory::class, // bleibt
65
                ]
66
            ],
67
            'routes' => [
68
                'markdown_cms:blog' => [
69
                    'name' => 'blog',
70
                    'path' => '/blog.{id:[^/]+}.html',
71
                    'middleware' => SingleBlogEntryAction::class,
72
                    'allowed_methods' => [
73
                        'GET'
74
                    ]
75
                ],
76
                'markdown_cms:blog_overview' => [
77
                    'name' => 'blog_overview',
78
                    'path' => '/blog.html',
79
                    'middleware' => BlogOverviewAction::class,
80
                    'allowed_methods' => [
81
                        'GET'
82
                    ]
83
                ],
84
                'markdown_cms:tags' => [
85
                    'name' => 'tags',
86
                    'path' => '/tag.{id}.html',
87
                    'middleware' => TagArchiveAction::class,
88
                    'allowed_methods' => [
89
                        'GET'
90
                    ]
91
                ],
92
                'markdown_cms:pages' => [
93
                    'name' => 'pages',
94
                    'path' => '/{id}.html',
95
                    'middleware' => SingleBlogEntryAction::class,
96
                    'allowed_methods' => [
97
                        'GET'
98
                    ]
99
                ],
100
            ],
101
        ];
102
    }
103
}