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

TextApiPageBase::main()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 18
rs 9.9332
c 1
b 0
f 0
cc 3
nc 3
nop 0
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