InfectionRaport   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 115
Duplicated Lines 7.83 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 15
c 1
b 0
f 0
lcom 1
cbo 0
dl 9
loc 115
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 3 1
A setId() 0 4 1
A getDataRaportu() 0 3 1
A setDataRaportu() 0 4 1
A getDataPrzeslania() 0 3 1
A setDataPrzeslania() 0 4 1
A getWard() 0 3 1
A setWard() 0 4 1
A getUser() 0 3 1
A setUser() 0 4 1
A __construct() 9 13 3
A toString() 0 10 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * Patient
5
 *
6
 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
7
 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
8
 *
9
 * Permission is hereby granted to use or copy this program
10
 * for any purpose, provided the above notices are retained on all copies.
11
 * Permission to modify the code and to distribute modified code is granted,
12
 * provided the above notices are retained, and a notice that the code was
13
 * modified is included with the above copyright notice.
14
 *
15
 * @category  Wp
16
 * @package   Punction
17
 * @author    Andrzej Marcinkowski <[email protected]>
18
 * @copyright 2014 Wojewódzki Szpital Zespolony, Kalisz
19
 * @license   MIT http://opensource.org/licenses/MIT
20
 * @version   1.0 $Id: 5e3d6d9fad27385cb557282c244e0767bf6c41e0 $ $Format:%H$
21
 * @link      http://
22
 * @since     File available since Release 1.0.0
23
 * PHP Version 5
24
 */
25
namespace Hospitalplugin\Entities;
26
27
/**
28
 * Infections
29
 *
30
 * @category Wp
31
 * @package Epidemio
32
 * @author Andrzej Marcinkowski <[email protected]>
33
 * @copyright 2014 Wojewódzki Szpital Zespolony, Kalisz
34
 * @license MIT http://opensource.org/licenses/MIT
35
 * @version 1.0 $Id: 5e3d6d9fad27385cb557282c244e0767bf6c41e0 $ $Format:%H$
36
 * @link http://
37
 * @since File available since Release 1.0.0
38
 *       
39
 */
40
class InfectionRaport {
41
	
42
	/**
43
	 * id
44
	 * @Id @Column(type="integer") @GeneratedValue
45
	 */
46
	public $id;
47
	
48
	/**
49
	 * $dataRaportu datetime
50
	 * @Column(type="datetime") *
51
	 */
52
	public $dataRaportu;
53
	
54
	/**
55
	 * $dataPrzeslania datetime
56
	 * @Column(type="datetime") *
57
	 */
58
	public $dataPrzeslania;
59
	
60
	/**
61
	 * @ManyToOne(targetEntity="Hospitalplugin\Entities\Ward")
62
	 * @JoinColumn(name="oddzialId", referencedColumnName="id")
63
	 */
64
	public $ward;
65
	
66
	/**
67
	 * @ManyToOne(targetEntity="Hospitalplugin\Entities\User")
68
	 * @JoinColumn(name="userId", referencedColumnName="id")
69
	 */
70
	protected $user;
71
	
72
	function __construct($args) {
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...
73 View Code Duplication
		foreach ( $args as $key => $value ) {
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...
74
			if ($key == 'dataRaportu') {
75
				$value = new \DateTime ( $value );
76
			} 
77
			call_user_func ( array (
78
					$this,
79
					'set' . $key 
80
			), $value );
81
		}
82
		$this->dataPrzeslania = new \DateTime ();
83
		echo '<h3><div class="alert alert-primary">Dziękuję za przesłanie raportu!</div></h3>';
84
	}
85
	
86
	/**
87
	 * getId
88
	 *
89
	 * @return id
90
	 */
91
	public function getId() {
92
		return $this->id;
93
	}
94
	
95
	/**
96
	 * sets id
97
	 *
98
	 * @param int $id
99
	 *        	ID
100
	 *        	
101
	 * @return \Hospitalplugin\Entities\Patient
102
	 */
103
	public function setId($id) {
104
		$this->id = $id;
105
		return $this;
106
	}
107
	
108
	/**
109
	 * toString
110
	 *
111
	 * @return string
112
	 */
113
	public function toString() {
114
		$txt = $this->getId ();
115
		$data = $this->getDataRaportu ();
116
		if ($data instanceof \DateTime) {
117
			$txt .= $this->getDataRaportu ()->format ( "Y-m-d" );
118
		} else {
119
			$txt .= $this->getDataRaportu ();
120
		}
121
		return $txt;
122
	}
123
	public function getDataRaportu() {
124
		return $this->dataRaportu;
125
	}
126
	public function setDataRaportu($dataRaportu) {
127
		$this->dataRaportu = $dataRaportu;
128
		return $this;
129
	}
130
	
131
	public function getDataPrzeslania() {
132
		return $this->dataPrzeslania;
133
	}
134
	public function setDataPrzeslania($dataPrzeslania) {
135
		$this->dataPrzeslania = $dataPrzeslania;
136
		return $this;
137
	}
138
	public function getWard() {
139
		return $this->ward;
140
	}
141
	public function setWard($ward) {
142
		$this->ward = $ward;
143
		return $this;
144
	}
145
	public function getUser() {
146
		return $this->user;
147
	}
148
	public function setUser($user) {
149
		$this->user = $user;
150
		return $this;
151
	}
152
	
153
	
154
}
155