absences_RightSort
last analyzed

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 15
ccs 0
cts 0
cp 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
getSortKey() 0 1 ?
setSortKey() 0 1 ?
getSortLabel() 0 1 ?
getIconClassName() 0 1 ?
getId() 0 1 ?
1
<?php
2
/************************************************************************
3
 * OVIDENTIA http://www.ovidentia.org                                   *
4
 ************************************************************************
5
 * Copyright (c) 2003 by CANTICO ( http://www.cantico.fr )              *
6
 *                                                                      *
7
 * This file is part of Ovidentia.                                      *
8
 *                                                                      *
9
 * Ovidentia is free software; you can redistribute it and/or modify    *
10
 * it under the terms of the GNU General Public License as published by *
11
 * the Free Software Foundation; either version 2, or (at your option)  *
12
 * any later version.													*
13
 *																		*
14
 * This program is distributed in the hope that it will be useful, but  *
15
 * WITHOUT ANY WARRANTY; without even the implied warranty of			*
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.					*
17
 * See the  GNU General Public License for more details.				*
18
 *																		*
19
 * You should have received a copy of the GNU General Public License	*
20
 * along with this program; if not, write to the Free Software			*
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,*
22
 * USA.																	*
23
************************************************************************/
24
25
require_once $GLOBALS['babInstallPath'].'utilit/iterator/iterator.php';
26
27
28
abstract class absences_Record
29
{
30
	/**
31
	 *
32
	 * @var int
33
	 */
34
	public $id;
35
	
36
	/**
37
	 *
38
	 * @var array
39
	 */
40
	protected $row;
41
	
42
	
43
	/**
44
	 * Set table row as an array
45
	 * @param array $row
46
	 * @return absences_Right
47
	 */
48 95
	public function setRow($row)
49
	{
50 95
		if (isset($row['id']))
51 95
		{
52 92
			$this->id = $row['id'];
53 92
		}
54 95
		$this->row = $row;
55 95
		return $this;
56
	}
57
	
58
	abstract public function getRow();
59
	
60 57
	public function __isset($property)
61
	{
62 57
		$row = $this->getRow();
63 57
		return isset($row[$property]);
64
	}
65
	
66 89 View Code Duplication
	public function __get($property)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
67
	{
68 89
		$row = $this->getRow();
69
		
70 89
		if (!isset($row[$property]))
71 89
		{
72
			require_once $GLOBALS['babInstallPath'].'utilit/devtools.php';
73
			bab_debug_print_backtrace();
74
			bab_debug($row);
75
			throw new Exception(sprintf('Failed to load property %s on %s', $property, get_class($this)));
76
		}
77
		
78 89
		return $row[$property];
79
	}
80
	
81 78
	public function __set($property, $value)
82
	{
83 78
		if (!isset($this->row))
84 78
		{
85 65
			if (isset($this->id))
86 65
			{
87 15
				$this->row = $this->getRow();
88 15
			} else {
89 63
				$this->row = array();
90
			}
91 65
		}
92
		
93 78
		$this->row[$property] = $value;
94
		
95 78
	}
96
	
97
	
98
	public function getId()
99
	{
100
	    return $this->id;
101
	}
102
}
103
104
105
106
107
108
109
110
111
112
/**
113
 *
114
 *
115
 */
116
abstract class absences_Iterator extends BAB_MySqlResultIterator
117
{
118
119
	
120 4
	protected function getRowByPrefix($data, $prefix)
121
	{
122 4
		$row = array();
123 4
		foreach($data as $key => $value)
124
		{
125 4
			if ($prefix === mb_substr($key, 0, mb_strlen($prefix)))
126 4
			{
127 4
				$row[mb_substr($key, mb_strlen($prefix) + 2)] = $value;
128 4
			}
129 4
		}
130
131 4
		return $row;
132
	}
133
134
	
135
}
136
137
138
139
interface absences_RightSort
140
{
141
	/**
142
	 * Method used with bab_Sort
143
	 */
144
	public function getSortKey();
145
	
146
	public function setSortKey($i);
147
	
148
	public function getSortLabel();
149
	
150
	public function getIconClassName();
151
	
152
	public function getId();
153
}