Skip to content
This repository was archived by the owner on Sep 20, 2021. It is now read-only.

Commit c92c1e6

Browse files
committed
Move to PSR-1 and PSR-2, and drop from/import.
1 parent a6fcf43 commit c92c1e6

File tree

5 files changed

+203
-346
lines changed

5 files changed

+203
-346
lines changed

Exception.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* New BSD License
1010
*
11-
* Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
11+
* Copyright © 2007-2015, Hoa community. All rights reserved.
1212
*
1313
* Redistribution and use in source and binary forms, with or without
1414
* modification, are permitted provided that the following conditions are met:
@@ -34,18 +34,18 @@
3434
* POSSIBILITY OF SUCH DAMAGE.
3535
*/
3636

37-
namespace Hoa\Stringbuffer {
37+
namespace Hoa\Stringbuffer;
38+
39+
use Hoa\Core;
3840

3941
/**
4042
* Class \Hoa\Stringbuffer\Exception.
4143
*
4244
* Extending the \Hoa\Core\Exception class.
4345
*
44-
* @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
45-
* @copyright Copyright © 2007-2015 Ivan Enderlin.
46+
* @copyright Copyright © 2007-2015 Hoa community
4647
* @license New BSD License
4748
*/
48-
49-
class Exception extends \Hoa\Core\Exception { }
50-
49+
class Exception extends Core\Exception
50+
{
5151
}

Read.php

Lines changed: 37 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* New BSD License
1010
*
11-
* Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
11+
* Copyright © 2007-2015, Hoa community. All rights reserved.
1212
*
1313
* Redistribution and use in source and binary forms, with or without
1414
* modification, are permitted provided that the following conditions are met:
@@ -34,185 +34,154 @@
3434
* POSSIBILITY OF SUCH DAMAGE.
3535
*/
3636

37-
namespace {
37+
namespace Hoa\Stringbuffer;
3838

39-
from('Hoa')
40-
41-
/**
42-
* \Hoa\Stringbuffer\Exception
43-
*/
44-
-> import('Stringbuffer.Exception')
45-
46-
/**
47-
* \Hoa\Stringbuffer
48-
*/
49-
-> import('Stringbuffer.~')
50-
51-
/**
52-
* \Hoa\Stream\IStream\In
53-
*/
54-
-> import('Stream.I~.In');
55-
56-
}
57-
58-
namespace Hoa\Stringbuffer {
39+
use Hoa\Stream;
5940

6041
/**
6142
* Class \Hoa\Stringbuffer\Read.
6243
*
6344
* Read a string buffer.
6445
*
65-
* @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
66-
* @copyright Copyright © 2007-2015 Ivan Enderlin.
46+
* @copyright Copyright © 2007-2015 Hoa community
6747
* @license New BSD License
6848
*/
69-
70-
class Read extends Stringbuffer implements \Hoa\Stream\IStream\In {
71-
49+
class Read extends Stringbuffer implements Stream\IStream\In
50+
{
7251
/**
7352
* Test for end-of-file.
7453
*
75-
* @access public
7654
* @return bool
7755
*/
78-
public function eof ( ) {
79-
56+
public function eof()
57+
{
8058
return feof($this->getStream());
8159
}
8260

8361
/**
8462
* Read n characters.
8563
*
86-
* @access public
8764
* @param int $length Length.
8865
* @return string
89-
* @throw \Hoa\Stringbuffer\Exception
66+
* @throws \Hoa\Stringbuffer\Exception
9067
*/
91-
public function read ( $length ) {
92-
93-
if(0 > $length)
68+
public function read($length)
69+
{
70+
if (0 > $length) {
9471
throw new Exception(
95-
'Length must be greater than 0, given %d.', 0, $length);
72+
'Length must be greater than 0, given %d.',
73+
0,
74+
$length
75+
);
76+
}
9677

9778
return fread($this->getStream(), $length);
9879
}
9980

10081
/**
10182
* Alias of $this->read().
10283
*
103-
* @access public
10484
* @param int $length Length.
10585
* @return string
10686
*/
107-
public function readString ( $length ) {
108-
87+
public function readString($length)
88+
{
10989
return $this->read($length);
11090
}
11191

11292
/**
11393
* Read a character.
11494
*
115-
* @access public
11695
* @return string
11796
*/
118-
public function readCharacter ( ) {
119-
97+
public function readCharacter()
98+
{
12099
return fgetc($this->getStream());
121100
}
122101

123102
/**
124103
* Read a boolean.
125104
*
126-
* @access public
127105
* @return bool
128106
*/
129-
public function readBoolean ( ) {
130-
107+
public function readBoolean()
108+
{
131109
return (bool) $this->read(1);
132110
}
133111

134112
/**
135113
* Read an integer.
136114
*
137-
* @access public
138115
* @param int $length Length.
139116
* @return int
140117
*/
141-
public function readInteger ( $length = 1 ) {
142-
118+
public function readInteger($length = 1)
119+
{
143120
return (int) $this->read($length);
144121
}
145122

146123
/**
147124
* Read a float.
148125
*
149-
* @access public
150126
* @param int $length Length.
151127
* @return float
152128
*/
153-
public function readFloat ( $length = 1 ) {
154-
129+
public function readFloat($length = 1)
130+
{
155131
return (float) $this->read($length);
156132
}
157133

158134
/**
159135
* Read an array.
160136
* Alias of the $this->scanf() method.
161137
*
162-
* @access public
163138
* @param string $format Format (see printf's formats).
164139
* @return array
165140
*/
166-
public function readArray ( $format = null ) {
167-
141+
public function readArray($format = null)
142+
{
168143
return $this->scanf($format);
169144
}
170145

171146
/**
172147
* Read a line.
173148
*
174-
* @access public
175149
* @return string
176150
*/
177-
public function readLine ( ) {
178-
151+
public function readLine()
152+
{
179153
return fgets($this->getStream());
180154
}
181155

182156
/**
183157
* Read all, i.e. read as much as possible.
184158
*
185-
* @access public
186159
* @param int $offset Offset.
187160
* @return string
188161
*/
189-
public function readAll ( $offset = 0 ) {
190-
162+
public function readAll($offset = 0)
163+
{
191164
return stream_get_contents($this->getStream(), -1, $offset);
192165
}
193166

194167
/**
195168
* Parse input from a stream according to a format.
196169
*
197-
* @access public
198170
* @param string $format Format (see printf's formats).
199171
* @return array
200172
*/
201-
public function scanf ( $format ) {
202-
173+
public function scanf($format)
174+
{
203175
return fscanf($this->getStream(), $format);
204176
}
205177

206178
/**
207179
* Transform this object to a string.
208180
*
209-
* @access public
210181
* @return string
211182
*/
212-
public function __toString ( ) {
213-
183+
public function __toString()
184+
{
214185
return $this->readAll();
215186
}
216187
}
217-
218-
}

0 commit comments

Comments
 (0)