Skip to content

Commit 4f8c9bf

Browse files
author
MarkBaker
committed
More PSR-2 work
1 parent 3c3154c commit 4f8c9bf

15 files changed

+1316
-1358
lines changed

Classes/PHPExcel/RichText.php

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
2+
23
/**
3-
* PHPExcel
4+
* PHPExcel_RichText
45
*
56
* Copyright (c) 2006 - 2015 PHPExcel
67
*
@@ -24,23 +25,14 @@
2425
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2526
* @version ##VERSION##, ##DATE##
2627
*/
27-
28-
29-
/**
30-
* PHPExcel_RichText
31-
*
32-
* @category PHPExcel
33-
* @package PHPExcel_RichText
34-
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
35-
*/
3628
class PHPExcel_RichText implements PHPExcel_IComparable
3729
{
3830
/**
3931
* Rich text elements
4032
*
4133
* @var PHPExcel_RichText_ITextElement[]
4234
*/
43-
private $_richTextElements;
35+
private $richTextElements;
4436

4537
/**
4638
* Create a new PHPExcel_RichText instance
@@ -51,10 +43,10 @@ class PHPExcel_RichText implements PHPExcel_IComparable
5143
public function __construct(PHPExcel_Cell $pCell = null)
5244
{
5345
// Initialise variables
54-
$this->_richTextElements = array();
46+
$this->richTextElements = array();
5547

5648
// Rich-Text string attached to cell?
57-
if ($pCell !== NULL) {
49+
if ($pCell !== null) {
5850
// Add cell text and style
5951
if ($pCell->getValue() != "") {
6052
$objRun = new PHPExcel_RichText_Run($pCell->getValue());
@@ -76,7 +68,7 @@ public function __construct(PHPExcel_Cell $pCell = null)
7668
*/
7769
public function addText(PHPExcel_RichText_ITextElement $pText = null)
7870
{
79-
$this->_richTextElements[] = $pText;
71+
$this->richTextElements[] = $pText;
8072
return $this;
8173
}
8274

@@ -119,7 +111,7 @@ public function getPlainText()
119111
$returnValue = '';
120112

121113
// Loop through all PHPExcel_RichText_ITextElement
122-
foreach ($this->_richTextElements as $text) {
114+
foreach ($this->richTextElements as $text) {
123115
$returnValue .= $text->getText();
124116
}
125117

@@ -144,7 +136,7 @@ public function __toString()
144136
*/
145137
public function getRichTextElements()
146138
{
147-
return $this->_richTextElements;
139+
return $this->richTextElements;
148140
}
149141

150142
/**
@@ -157,7 +149,7 @@ public function getRichTextElements()
157149
public function setRichTextElements($pElements = null)
158150
{
159151
if (is_array($pElements)) {
160-
$this->_richTextElements = $pElements;
152+
$this->richTextElements = $pElements;
161153
} else {
162154
throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed.");
163155
}
@@ -172,13 +164,13 @@ public function setRichTextElements($pElements = null)
172164
public function getHashCode()
173165
{
174166
$hashElements = '';
175-
foreach ($this->_richTextElements as $element) {
167+
foreach ($this->richTextElements as $element) {
176168
$hashElements .= $element->getHashCode();
177169
}
178170

179171
return md5(
180-
$hashElements
181-
. __CLASS__
172+
$hashElements .
173+
__CLASS__
182174
);
183175
}
184176

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
2+
23
/**
3-
* PHPExcel
4+
* PHPExcel_RichText_ITextElement
45
*
56
* This library is free software; you can redistribute it and/or
67
* modify it under the terms of the GNU Lesser General Public
@@ -19,46 +20,37 @@
1920
* @category PHPExcel
2021
* @package PHPExcel_RichText
2122
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
22-
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
23+
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2324
* @version ##VERSION##, ##DATE##
2425
*/
25-
26-
27-
/**
28-
* PHPExcel_RichText_ITextElement
29-
*
30-
* @category PHPExcel
31-
* @package PHPExcel_RichText
32-
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
33-
*/
3426
interface PHPExcel_RichText_ITextElement
3527
{
36-
/**
37-
* Get text
38-
*
39-
* @return string Text
40-
*/
41-
public function getText();
28+
/**
29+
* Get text
30+
*
31+
* @return string Text
32+
*/
33+
public function getText();
4234

43-
/**
44-
* Set text
45-
*
46-
* @param $pText string Text
47-
* @return PHPExcel_RichText_ITextElement
48-
*/
49-
public function setText($pText = '');
35+
/**
36+
* Set text
37+
*
38+
* @param $pText string Text
39+
* @return PHPExcel_RichText_ITextElement
40+
*/
41+
public function setText($pText = '');
5042

51-
/**
52-
* Get font
53-
*
54-
* @return PHPExcel_Style_Font
55-
*/
56-
public function getFont();
43+
/**
44+
* Get font
45+
*
46+
* @return PHPExcel_Style_Font
47+
*/
48+
public function getFont();
5749

58-
/**
59-
* Get hash code
60-
*
61-
* @return string Hash code
62-
*/
63-
public function getHashCode();
50+
/**
51+
* Get hash code
52+
*
53+
* @return string Hash code
54+
*/
55+
public function getHashCode();
6456
}

Classes/PHPExcel/RichText/Run.php

Lines changed: 60 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
2+
23
/**
3-
* PHPExcel
4+
* PHPExcel_RichText_Run
45
*
56
* This library is free software; you can redistribute it and/or
67
* modify it under the terms of the GNU Lesser General Public
@@ -19,84 +20,79 @@
1920
* @category PHPExcel
2021
* @package PHPExcel_RichText
2122
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
22-
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
23+
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2324
* @version ##VERSION##, ##DATE##
2425
*/
25-
26-
27-
/**
28-
* PHPExcel_RichText_Run
29-
*
30-
* @category PHPExcel
31-
* @package PHPExcel_RichText
32-
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
33-
*/
3426
class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
3527
{
36-
/**
37-
* Font
38-
*
39-
* @var PHPExcel_Style_Font
40-
*/
41-
private $_font;
28+
/**
29+
* Font
30+
*
31+
* @var PHPExcel_Style_Font
32+
*/
33+
private $font;
4234

4335
/**
4436
* Create a new PHPExcel_RichText_Run instance
4537
*
46-
* @param string $pText Text
38+
* @param string $pText Text
4739
*/
4840
public function __construct($pText = '')
4941
{
50-
// Initialise variables
51-
$this->setText($pText);
52-
$this->_font = new PHPExcel_Style_Font();
42+
// Initialise variables
43+
$this->setText($pText);
44+
$this->font = new PHPExcel_Style_Font();
5345
}
5446

55-
/**
56-
* Get font
57-
*
58-
* @return PHPExcel_Style_Font
59-
*/
60-
public function getFont() {
61-
return $this->_font;
62-
}
47+
/**
48+
* Get font
49+
*
50+
* @return PHPExcel_Style_Font
51+
*/
52+
public function getFont()
53+
{
54+
return $this->font;
55+
}
6356

64-
/**
65-
* Set font
66-
*
67-
* @param PHPExcel_Style_Font $pFont Font
68-
* @throws PHPExcel_Exception
69-
* @return PHPExcel_RichText_ITextElement
70-
*/
71-
public function setFont(PHPExcel_Style_Font $pFont = null) {
72-
$this->_font = $pFont;
73-
return $this;
74-
}
57+
/**
58+
* Set font
59+
*
60+
* @param PHPExcel_Style_Font $pFont Font
61+
* @throws PHPExcel_Exception
62+
* @return PHPExcel_RichText_ITextElement
63+
*/
64+
public function setFont(PHPExcel_Style_Font $pFont = null)
65+
{
66+
$this->font = $pFont;
67+
return $this;
68+
}
7569

76-
/**
77-
* Get hash code
78-
*
79-
* @return string Hash code
80-
*/
81-
public function getHashCode() {
82-
return md5(
83-
$this->getText()
84-
. $this->_font->getHashCode()
85-
. __CLASS__
86-
);
70+
/**
71+
* Get hash code
72+
*
73+
* @return string Hash code
74+
*/
75+
public function getHashCode()
76+
{
77+
return md5(
78+
$this->getText() .
79+
$this->_font->getHashCode() .
80+
__CLASS__
81+
);
8782
}
8883

89-
/**
90-
* Implement PHP __clone to create a deep clone, not just a shallow copy.
91-
*/
92-
public function __clone() {
93-
$vars = get_object_vars($this);
94-
foreach ($vars as $key => $value) {
95-
if (is_object($value)) {
96-
$this->$key = clone $value;
97-
} else {
98-
$this->$key = $value;
99-
}
100-
}
101-
}
84+
/**
85+
* Implement PHP __clone to create a deep clone, not just a shallow copy.
86+
*/
87+
public function __clone()
88+
{
89+
$vars = get_object_vars($this);
90+
foreach ($vars as $key => $value) {
91+
if (is_object($value)) {
92+
$this->$key = clone $value;
93+
} else {
94+
$this->$key = $value;
95+
}
96+
}
97+
}
10298
}

0 commit comments

Comments
 (0)