Passed
Push — task/3376-TYPO3_12_compatibili... ( dc7e5a...379ca7 )
by Rafael
40:48
created

AllowUrlFOpenStatus   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 17
c 0
b 0
f 0
dl 0
loc 44
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getStatus() 0 29 2
A getLabel() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
namespace ApacheSolrForTypo3\Solr\Report;
19
20
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
21
use TYPO3\CMS\Core\Utility\GeneralUtility;
22
use TYPO3\CMS\Reports\Status;
23
24
/**
25
 * Provides a status report about whether the php.ini setting allow_url_fopen
26
 * is activated or not.
27
 *
28
 * @author Ingo Renner <[email protected]>
29
 */
30
class AllowUrlFOpenStatus extends AbstractSolrStatus
31
{
32
    /**
33
     * Checks whether allow_url_fopen is enabled.
34
     *
35
     * @return array
36
     */
37
    public function getStatus(): array
38
    {
39
        $reports = [];
40
        $severity = ContextualFeedbackSeverity::OK;
41
        $value = 'On';
42
        $message = '';
43
44
        if (!ini_get('allow_url_fopen')) {
45
            $severity = ContextualFeedbackSeverity::ERROR;
46
            $value = 'Off';
47
            $message = 'allow_url_fopen must be enabled in php.ini to allow
48
				communication between TYPO3 and the Apache Solr server.
49
				Indexing pages using the Index Queue will also not work with
50
				this setting disabled.';
51
        }
52
53
        $reports[] = GeneralUtility::makeInstance(
54
            Status::class,
55
            /** @scrutinizer ignore-type */
56
            'allow_url_fopen',
57
            /** @scrutinizer ignore-type */
58
            $value,
59
            /** @scrutinizer ignore-type */
60
            $message,
61
            /** @scrutinizer ignore-type */
62
            $severity
63
        );
64
65
        return $reports;
66
    }
67
68
    /**
69
     * {@inheritDoc}
70
     */
71
    public function getLabel(): string
72
    {
73
        return 'solr/allow-url-open';
74
    }
75
}
76