Skip to content

Commit 3709a0f

Browse files
committed
#12 : Cleaning some unuseful code
1 parent 5405324 commit 3709a0f

File tree

4 files changed

+31
-59
lines changed

4 files changed

+31
-59
lines changed

samples/Sample_01_Simple.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
$objTask21->setEndDate('04-01-2012');
5151
$objTask21->setProgress(1);
5252
$objTask21->addResource($objRes2);
53+
$objTask21->addResource($objRes1);
5354
$objTask21Res = $objTask21->getResources();
5455
echo 'Resources "Analysis Code"'.EOL;
5556
foreach ($objTask21Res as $res){

src/PhpProject/PhpProject.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ public function setInformations(DocumentInformations $pValue)
136136
*/
137137
public function createResource()
138138
{
139-
$newRessource = new Resource($this, $this->getResourceCount());
139+
$newRessource = new Resource();
140+
$newRessource->setIndex($this->getResourceCount());
140141
$this->resourceCollection[] = $newRessource;
141142
$this->activeResourceIndex = $this->getResourceCount() - 1;
142143
return $newRessource;
@@ -226,7 +227,8 @@ private function setActiveResourceIndex($pIndex = 0)
226227
*/
227228
public function createTask()
228229
{
229-
$newTask = new Task($this, $this->getTaskCount());
230+
$newTask = new Task();
231+
$newTask->setIndex($this->getTaskCount());
230232
$this->taskCollection[] = $newTask;
231233
$this->activeTaskIndex = $this->getTaskCount() - 1;
232234
return $newTask;

src/PhpProject/Resource.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,15 @@ class Resource
3333
*/
3434
private $title;
3535

36-
/**
37-
* Parent Project
38-
*
39-
* @var PHPProject
40-
*/
41-
private $parent;
42-
4336
/**
4437
* Index
4538
*
4639
* @var integer
4740
*/
4841
private $index;
4942

50-
public function __construct(PhpProject $pParent, $pIndex)
43+
public function __construct()
5144
{
52-
$this->parent = $pParent;
53-
$this->index = $pIndex;
5445
}
5546

5647
/**
@@ -86,12 +77,11 @@ public function getIndex()
8677
}
8778

8879
/**
89-
* Get parent
90-
*
91-
* @return PHPProject
80+
* Set index
9281
*/
93-
public function getParent()
82+
public function setIndex($value)
9483
{
95-
return $this->parent;
84+
$this->index = $value;
85+
return $this;
9686
}
9787
}

src/PhpProject/Task.php

Lines changed: 21 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,6 @@ class Task
6161
*/
6262
private $progress;
6363

64-
/**
65-
* Parent Project
66-
*
67-
* @var PHPProject
68-
*/
69-
private $parentProject;
70-
71-
/**
72-
* Parent Task
73-
*
74-
* @var PHPProject_Task
75-
*/
76-
private $parentTask;
77-
7864
/**
7965
* Index
8066
*
@@ -87,7 +73,7 @@ class Task
8773
*
8874
* @var integer[]
8975
*/
90-
private $resourceCollection;
76+
private $resourceCollection = array();
9177

9278
/**
9379
* Collection of task objects
@@ -103,33 +89,8 @@ class Task
10389
*/
10490
private $_activeTaskIndex = 0;
10591

106-
public function __construct(PhpProject $pParent, $pIndex, Task $pParentTask = null)
107-
{
108-
$this->parentProject = $pParent;
109-
$this->parentTask = $pParentTask;
110-
$this->index = $pIndex;
111-
112-
$this->resourceCollection = array();
113-
}
114-
115-
/**
116-
* Get parent
117-
*
118-
* @return PHPProject
119-
*/
120-
public function getParent()
121-
{
122-
return $this->_parent;
123-
}
124-
125-
/**
126-
* Get parent task
127-
*
128-
* @return PHPProject_Task
129-
*/
130-
public function getParentTask()
92+
public function __construct()
13193
{
132-
return $this->parentTask;
13394
}
13495

13596
/**
@@ -268,6 +229,23 @@ public function setProgress($pValue = 0)
268229
return $this;
269230
}
270231

232+
/**
233+
* Get index
234+
*/
235+
public function getIndex()
236+
{
237+
return $this->index;
238+
}
239+
240+
/**
241+
* Set index
242+
*/
243+
public function setIndex($value)
244+
{
245+
$this->index = $value;
246+
return $this;
247+
}
248+
271249
//===============================================
272250
// Resources
273251
//===============================================
@@ -303,7 +281,8 @@ public function getResourceCount()
303281
//===============================================
304282
public function createTask()
305283
{
306-
$newTask = new self($this->parentProject, $this->getTaskCount(), $this);
284+
$newTask = new self();
285+
$newTask->setIndex($this->getTaskCount());
307286
$this->taskCollection[] = $newTask;
308287
$this->_activeTaskIndex = $this->getTaskCount() - 1;
309288
return $newTask;

0 commit comments

Comments
 (0)