Skip to content

Commit 49783ef

Browse files
author
Dominik Bonsch
committed
PSR-2
1 parent b997041 commit 49783ef

File tree

1 file changed

+90
-87
lines changed

1 file changed

+90
-87
lines changed

Classes/PHPExcel/RichText.php

Lines changed: 90 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @category PHPExcel
2222
* @package PHPExcel_RichText
2323
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
24-
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
24+
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2525
* @version ##VERSION##, ##DATE##
2626
*/
2727

@@ -35,77 +35,77 @@
3535
*/
3636
class PHPExcel_RichText implements PHPExcel_IComparable
3737
{
38-
/**
39-
* Rich text elements
40-
*
41-
* @var PHPExcel_RichText_ITextElement[]
42-
*/
43-
private $_richTextElements;
38+
/**
39+
* Rich text elements
40+
*
41+
* @var PHPExcel_RichText_ITextElement[]
42+
*/
43+
private $_richTextElements;
4444

4545
/**
4646
* Create a new PHPExcel_RichText instance
4747
*
48-
* @param PHPExcel_Cell $pParent
49-
* @throws PHPExcel_Exception
48+
* @param PHPExcel_Cell $pParent
49+
* @throws PHPExcel_Exception
5050
*/
5151
public function __construct(PHPExcel_Cell $pCell = null)
5252
{
53-
// Initialise variables
54-
$this->_richTextElements = array();
55-
56-
// Rich-Text string attached to cell?
57-
if ($pCell !== NULL) {
58-
// Add cell text and style
59-
if ($pCell->getValue() != "") {
60-
$objRun = new PHPExcel_RichText_Run($pCell->getValue());
61-
$objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont());
62-
$this->addText($objRun);
63-
}
64-
65-
// Set parent value
66-
$pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
67-
}
53+
// Initialise variables
54+
$this->_richTextElements = array();
55+
56+
// Rich-Text string attached to cell?
57+
if ($pCell !== NULL) {
58+
// Add cell text and style
59+
if ($pCell->getValue() != "") {
60+
$objRun = new PHPExcel_RichText_Run($pCell->getValue());
61+
$objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont());
62+
$this->addText($objRun);
63+
}
64+
65+
// Set parent value
66+
$pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
67+
}
6868
}
6969

7070
/**
7171
* Add text
7272
*
73-
* @param PHPExcel_RichText_ITextElement $pText Rich text element
74-
* @throws PHPExcel_Exception
73+
* @param PHPExcel_RichText_ITextElement $pText Rich text element
74+
* @throws PHPExcel_Exception
7575
* @return PHPExcel_RichText
7676
*/
7777
public function addText(PHPExcel_RichText_ITextElement $pText = null)
7878
{
79-
$this->_richTextElements[] = $pText;
80-
return $this;
79+
$this->_richTextElements[] = $pText;
80+
return $this;
8181
}
8282

8383
/**
8484
* Create text
8585
*
86-
* @param string $pText Text
87-
* @return PHPExcel_RichText_TextElement
88-
* @throws PHPExcel_Exception
86+
* @param string $pText Text
87+
* @return PHPExcel_RichText_TextElement
88+
* @throws PHPExcel_Exception
8989
*/
9090
public function createText($pText = '')
9191
{
92-
$objText = new PHPExcel_RichText_TextElement($pText);
93-
$this->addText($objText);
94-
return $objText;
92+
$objText = new PHPExcel_RichText_TextElement($pText);
93+
$this->addText($objText);
94+
return $objText;
9595
}
9696

9797
/**
9898
* Create text run
9999
*
100-
* @param string $pText Text
101-
* @return PHPExcel_RichText_Run
102-
* @throws PHPExcel_Exception
100+
* @param string $pText Text
101+
* @return PHPExcel_RichText_Run
102+
* @throws PHPExcel_Exception
103103
*/
104104
public function createTextRun($pText = '')
105105
{
106-
$objText = new PHPExcel_RichText_Run($pText);
107-
$this->addText($objText);
108-
return $objText;
106+
$objText = new PHPExcel_RichText_Run($pText);
107+
$this->addText($objText);
108+
return $objText;
109109
}
110110

111111
/**
@@ -115,25 +115,26 @@ public function createTextRun($pText = '')
115115
*/
116116
public function getPlainText()
117117
{
118-
// Return value
119-
$returnValue = '';
118+
// Return value
119+
$returnValue = '';
120120

121-
// Loop through all PHPExcel_RichText_ITextElement
122-
foreach ($this->_richTextElements as $text) {
123-
$returnValue .= $text->getText();
124-
}
121+
// Loop through all PHPExcel_RichText_ITextElement
122+
foreach ($this->_richTextElements as $text) {
123+
$returnValue .= $text->getText();
124+
}
125125

126-
// Return
127-
return $returnValue;
126+
// Return
127+
return $returnValue;
128128
}
129129

130130
/**
131131
* Convert to string
132132
*
133133
* @return string
134134
*/
135-
public function __toString() {
136-
return $this->getPlainText();
135+
public function __toString()
136+
{
137+
return $this->getPlainText();
137138
}
138139

139140
/**
@@ -143,54 +144,56 @@ public function __toString() {
143144
*/
144145
public function getRichTextElements()
145146
{
146-
return $this->_richTextElements;
147+
return $this->_richTextElements;
147148
}
148149

149150
/**
150151
* Set Rich Text elements
151152
*
152-
* @param PHPExcel_RichText_ITextElement[] $pElements Array of elements
153-
* @throws PHPExcel_Exception
153+
* @param PHPExcel_RichText_ITextElement[] $pElements Array of elements
154+
* @throws PHPExcel_Exception
154155
* @return PHPExcel_RichText
155156
*/
156157
public function setRichTextElements($pElements = null)
157158
{
158-
if (is_array($pElements)) {
159-
$this->_richTextElements = $pElements;
160-
} else {
161-
throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed.");
162-
}
163-
return $this;
159+
if (is_array($pElements)) {
160+
$this->_richTextElements = $pElements;
161+
} else {
162+
throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed.");
163+
}
164+
return $this;
164165
}
165166

166-
/**
167-
* Get hash code
168-
*
169-
* @return string Hash code
170-
*/
171-
public function getHashCode() {
172-
$hashElements = '';
173-
foreach ($this->_richTextElements as $element) {
174-
$hashElements .= $element->getHashCode();
175-
}
176-
177-
return md5(
178-
$hashElements
179-
. __CLASS__
180-
);
167+
/**
168+
* Get hash code
169+
*
170+
* @return string Hash code
171+
*/
172+
public function getHashCode()
173+
{
174+
$hashElements = '';
175+
foreach ($this->_richTextElements as $element) {
176+
$hashElements .= $element->getHashCode();
177+
}
178+
179+
return md5(
180+
$hashElements
181+
. __CLASS__
182+
);
181183
}
182184

183-
/**
184-
* Implement PHP __clone to create a deep clone, not just a shallow copy.
185-
*/
186-
public function __clone() {
187-
$vars = get_object_vars($this);
188-
foreach ($vars as $key => $value) {
189-
if (is_object($value)) {
190-
$this->$key = clone $value;
191-
} else {
192-
$this->$key = $value;
193-
}
194-
}
195-
}
185+
/**
186+
* Implement PHP __clone to create a deep clone, not just a shallow copy.
187+
*/
188+
public function __clone()
189+
{
190+
$vars = get_object_vars($this);
191+
foreach ($vars as $key => $value) {
192+
if (is_object($value)) {
193+
$this->$key = clone $value;
194+
} else {
195+
$this->$key = $value;
196+
}
197+
}
198+
}
196199
}

0 commit comments

Comments
 (0)