Calendar_Server   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 38
dl 0
loc 55
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A Calendar_Server() 0 16 1
A __dispatch() 0 5 2
A getMonth() 0 25 4
1
<?php
2
/**
3
* Description: a SOAP Calendar Server
4
*/
5
if (!@include('SOAP'.DIRECTORY_SEPARATOR.'Server.php')) {
6
    die('You must have PEAR::SOAP installed');
7
}
8
9
if (!@include 'Calendar'.DIRECTORY_SEPARATOR.'Calendar.php') {
10
    define('CALENDAR_ROOT', '../../');
11
}
12
13
class Calendar_Server
14
{
15
    var $__dispatch_map = array();
16
    var $__typedef      = array();
17
18
    function Calendar_Server()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
19
    {
20
        $this->__dispatch_map['getMonth'] =
21
            array('in'  => array('year' => 'int', 'month'=>'int'),
22
                  'out' => array('month' => '{urn:PEAR_SOAP_Calendar}Month'),
23
                  );
24
        $this->__typedef['Month'] = array (
25
                'monthname' => 'string',
26
                'days' => '{urn:PEAR_SOAP_Calendar}MonthDays'
27
            );
28
        $this->__typedef['MonthDays'] = array (array ('{urn:PEAR_SOAP_Calendar}Day'));
29
        $this->__typedef['Day'] = array (
30
                'isFirst' => 'int',
31
                'isLast'  => 'int',
32
                'isEmpty' => 'int',
33
                'day'     => 'int' );
34
    }
35
36
    function __dispatch($methodname)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
37
    {
38
        if (isset($this->__dispatch_map[$methodname]))
39
            return $this->__dispatch_map[$methodname];
40
        return NULL;
41
    }
42
43
    function getMonth($year, $month)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
44
    {
45
        require_once(CALENDAR_ROOT.'Month'.DIRECTORY_SEPARATOR.'Weekdays.php');
46
        $Month = & new Calendar_Month_Weekdays($year,$month);
0 ignored issues
show
Bug introduced by
The type Calendar_Month_Weekdays was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
47
        if (!$Month->isValid()) {
48
            $V = & $Month->getValidator();
49
            $errorMsg = '';
50
            while ($error = $V->fetch()) {
51
                $errorMsg .= $error->toString()."\n";
52
            }
53
            return new SOAP_Fault($errorMsg, 'Client');
0 ignored issues
show
Bug introduced by
The type SOAP_Fault was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
54
        } else {
55
            $monthname = date('F Y', $Month->getTimeStamp());
56
            $days = array();
57
            $Month->build();
58
            while ($Day = & $Month->fetch()) {
59
                $day = array(
60
                    'isFirst' => (int)$Day->isFirst(),
61
                    'isLast'  => (int)$Day->isLast(),
62
                    'isEmpty' => (int)$Day->isEmpty(),
63
                    'day'     => (int)$Day->thisDay(),
64
                    );
65
                $days[] = $day;
66
            }
67
            return array('monthname' => $monthname, 'days' => $days);
68
        }
69
    }
70
}
71
72
$server = new SOAP_Server();
0 ignored issues
show
Bug introduced by
The type SOAP_Server was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
73
$server->_auto_translation = true;
74
$calendar = new Calendar_Server();
75
$server->addObjectMap($calendar, 'urn:PEAR_SOAP_Calendar');
76
77
if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') {
78
    $server->service($GLOBALS['HTTP_RAW_POST_DATA']);
79
} else {
80
    require_once 'SOAP'.DIRECTORY_SEPARATOR.'Disco.php';
81
    $disco = new SOAP_DISCO_Server($server, "PEAR_SOAP_Calendar");
0 ignored issues
show
Bug introduced by
The type SOAP_DISCO_Server was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
82
    if (isset($_SERVER['QUERY_STRING']) &&
83
        strcasecmp($_SERVER['QUERY_STRING'], 'wsdl')==0) {
84
        header("Content-type: text/xml");
85
        echo $disco->getWSDL();
86
    } else {
87
        echo 'This is a PEAR::SOAP Calendar Server. For client try <a href="8.php">here</a><br />';
88
        echo 'For WSDL try <a href="?wsdl">here</a>';
89
    }
90
    exit;
91
}
92
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...