Passed
Push — master ( f0ea8d...957864 )
by Simon
04:01
created

TextApiPageBase   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 11
dl 0
loc 20
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A main() 0 18 3
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 * ACC Development Team. Please see team.json for a list of contributors.     *
5
 *                                                                            *
6
 * This is free and unencumbered software released into the public domain.    *
7
 * Please see LICENSE.md for the full licencing statement.                    *
8
 ******************************************************************************/
9
10
namespace Waca\Tasks;
11
12
use Waca\API\ApiException as ApiException;
13
14
abstract class TextApiPageBase extends ApiPageBase implements IRoutedTask
15
{
16
    final protected function main()
17
    {
18
        if (headers_sent()) {
19
            throw new ApiException('Headers have already been sent - this indicates a bug in the application!');
20
        }
21
22
        try {
23
            $responseData = $this->runApiPage();
24
        }
25
        catch (ApiException $ex) {
26
            $responseData = $ex->getMessage();
27
        }
28
29
        header('Content-Type: text/plain');
30
31
        ob_end_clean();
32
        print($responseData);
33
        ob_start();
34
    }
35
}
36