functions.php ➔ caldav_getAttendeeProp()   B
last analyzed

Complexity

Conditions 6
Paths 10

Size

Total Lines 30

Duplication

Lines 14
Ratio 46.67 %

Code Coverage

Tests 18
CRAP Score 6.2163

Importance

Changes 0
Metric Value
cc 6
nc 10
nop 2
dl 14
loc 30
rs 8.8177
c 0
b 0
f 0
ccs 18
cts 22
cp 0.8182
crap 6.2163
1
<?php
2
//-------------------------------------------------------------------------
3
// OVIDENTIA http://www.ovidentia.org
4
// Ovidentia is free software; you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation; either version 2, or (at your option)
7
// any later version.
8
// 
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
// See the GNU General Public License for more details.
13
// 
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17
// USA.
18
//-------------------------------------------------------------------------
19
/**
20
 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
21
 * @copyright Copyright (c) 2006 by CANTICO ({@link http://www.cantico.fr})
22
 */
23
24
25
/**
26
 * Translates the string.
27
 *
28
 * @param string $str
29
 * @return string
30
 */
31
function caldav_translate($str)
32
{
33
	return bab_translate($str, 'LibCaldav');
0 ignored issues
show
Unused Code introduced by
The call to bab_translate() has too many arguments starting with 'LibCaldav'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
34
}
35
36
37
38
/**
39
 * Parse attendee property
40
 * @param string $iCalPropertyName
41
 * @return array
42
 */
43
function caldav_getAttendeeProp($iCalPropertyName, $iCalPropertyValue)
44
{
45 4
    $parameters = explode(';', $iCalPropertyName);
46 4
    array_shift($parameters);
47
     
48 4
    $role = null;
49 4
    $partstat = null;
50 4
    $cn = '';
51 4
    $email = null;
52
     
53 4 View Code Duplication
    foreach ($parameters as $parameter) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54 4
        list($paramName, $paramValue) = explode('=', $parameter);
55
        switch ($paramName) {
56 4
            case 'ROLE':
57
                $role = $paramValue;
58
                break;
59 4
            case 'PARTSTAT':
60
                $partstat = $paramValue;
61
                break;
62 4
            case 'CN':
63 4
                $cn = trim($paramValue, '" ');
64 4
                break;
65
        }
66 4
    }
67 4
    if (stripos($iCalPropertyValue, 'MAILTO:') !== false) {
68 4
        list(, $email) = explode(':', $iCalPropertyValue);
69 4
    }
70
     
71
    return array($role, $partstat, $cn, $email);
72
}