Skip to content

Commit 8a5870d

Browse files
committed
PSR2 fixed
1 parent cc45132 commit 8a5870d

14 files changed

+774
-970
lines changed

ComparisonString.php

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<?php
22
/**
3-
* MARCspec is the specification of a reference, encoded as string, to a set of data
3+
* MARCspec is the specification of a reference, encoded as string, to a set of data
44
* from within a MARC record.
5-
*
5+
*
66
* @author Carsten Klee <[email protected]>
77
* @package CK\MARCspec
8-
* @copyright For the full copyright and license information, please view the LICENSE
8+
* @copyright For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.
1010
*/
1111
namespace CK\MARCspec;
1212

1313
use CK\MARCspec\Exception\InvalidMARCspecException;
14+
1415
/**
1516
* A MARCspec comparison string class
1617
*/
@@ -19,28 +20,25 @@ class ComparisonString implements ComparisonStringInterface, \JsonSerializable,
1920

2021
/**
2122
* @var string The escaped comparison string
22-
*/
23+
*/
2324
private $raw;
2425

2526
/**
2627
*
2728
* {@inheritdoc}
28-
*
29-
* @throws \InvalidArgumentException if argument is not a string or
29+
*
30+
* @throws \InvalidArgumentException if argument is not a string or
3031
* comparison string is not properly escaped
3132
*/
3233
public function __construct($raw)
3334
{
3435

35-
if(!is_string($raw))
36-
{
36+
if (!is_string($raw)) {
3737
throw new \InvalidArgumentException('Argument must be of type string. Got '
38-
.gettype($raw).'.'
39-
);
38+
.gettype($raw).'.');
4039
}
4140

42-
if(false !== strpos($raw,' '))
43-
{
41+
if (false !== strpos($raw, ' ')) {
4442
throw new InvalidMARCspecException(
4543
InvalidMARCspecException::CS.
4644
InvalidMARCspecException::SPACE,
@@ -49,8 +47,7 @@ public function __construct($raw)
4947
}
5048

5149
/** char of list ${}!=~?|\s must be escaped if not at index 0*/
52-
if(!preg_match('/^(.(?:[^${}!=~?| ]|(?<=\\\\)[${}!=~?|])*)$/',$raw))
53-
{
50+
if (!preg_match('/^(.(?:[^${}!=~?| ]|(?<=\\\\)[${}!=~?|])*)$/', $raw)) {
5451
throw new InvalidMARCspecException(
5552
InvalidMARCspecException::CS.
5653
InvalidMARCspecException::ESCAPE,
@@ -66,7 +63,7 @@ public function __construct($raw)
6663
*/
6764
public function getComparable()
6865
{
69-
$comparable = str_replace('\s',' ',$this->raw);
66+
$comparable = str_replace('\s', ' ', $this->raw);
7067
return stripcslashes($comparable);
7168
}
7269

@@ -84,11 +81,10 @@ public function getRaw()
8481
public static function escape($arg)
8582
{
8683
$specialChars = ['{','}','!','=','~','?'];
87-
for($i = 0; $i < count($specialChars);$i++)
88-
{
89-
$arg = str_replace($specialChars[$i],'\\'.$specialChars[$i],$arg);
84+
for ($i = 0; $i < count($specialChars); $i++) {
85+
$arg = str_replace($specialChars[$i], '\\'.$specialChars[$i], $arg);
9086
}
91-
return $arg = str_replace(' ','\s',$arg);
87+
return $arg = str_replace(' ', '\s', $arg);
9288
}
9389

9490
/**
@@ -109,58 +105,61 @@ public function jsonSerialize()
109105

110106
/**
111107
* Access object like an associative array
112-
*
108+
*
113109
* @api
114-
*
110+
*
115111
* @param string $offset Key raw|comparable
116-
*/
112+
*/
117113
public function offsetExists($offset)
118114
{
119-
switch($offset)
120-
{
121-
case 'raw':
122-
case 'comparable': return true;
115+
switch ($offset) {
116+
case 'raw':
117+
case 'comparable':
118+
return true;
123119
break;
124-
default: return false;
120+
default:
121+
return false;
125122
}
126123
}
127124

128125
/**
129126
* Access object like an associative array
130-
*
127+
*
131128
* @api
132-
*
129+
*
133130
* @param string $offset Key operator|leftSubTerm|rightSubTerm
134-
*/
131+
*/
135132
public function offsetGet($offset)
136133
{
137-
switch($offset)
138-
{
139-
case 'raw': return $this->getRaw();
134+
switch ($offset) {
135+
case 'raw':
136+
return $this->getRaw();
140137
break;
141-
case 'comparable': return $this->getComparable();
138+
case 'comparable':
139+
return $this->getComparable();
142140
break;
143-
default: throw new \UnexpectedValueException("Offset $offset does not exist.");
141+
default:
142+
throw new \UnexpectedValueException("Offset $offset does not exist.");
144143
}
145144
}
146145

147146
/**
148147
* Access object like an associative array
149-
*
148+
*
150149
* @api
151-
*
150+
*
152151
* @param string $offset
153-
*/
154-
public function offsetSet($offset,$value)
152+
*/
153+
public function offsetSet($offset, $value)
155154
{
156155
throw new \UnexpectedValueException("Offset $offset cannot be set.");
157156
}
158157

159158
/**
160159
* Access object like an associative array
161-
*
160+
*
162161
* @param string $offset
163-
*/
162+
*/
164163
public function offsetUnset($offset)
165164
{
166165
throw new \BadMethodCallException("Offset $offset can not be unset.");

ComparisonStringInterface.php

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22
/**
3-
* MARCspec is the specification of a reference, encoded as string, to a set of data
3+
* MARCspec is the specification of a reference, encoded as string, to a set of data
44
* from within a MARC record.
5-
*
5+
*
66
* @author Carsten Klee <[email protected]>
77
* @package CK\MARCspec
8-
* @copyright For the full copyright and license information, please view the LICENSE
8+
* @copyright For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.
1010
*/
1111

@@ -19,38 +19,38 @@ interface ComparisonStringInterface
1919

2020
/**
2121
* Constructor for ComparisonString
22-
*
22+
*
2323
* @api
24-
*
24+
*
2525
* @param string $raw The escaped comparison string
2626
*/
2727
public function __construct($raw);
2828

2929
/**
3030
* Get unescaped comparable string
31-
*
31+
*
3232
* @api
33-
*
33+
*
3434
* @return string The comparable string
3535
*/
3636
public function getComparable();
3737

3838
/**
3939
* Get raw escaped string
40-
*
40+
*
4141
* @api
42-
*
42+
*
4343
* @return string The escaped string
4444
*/
4545
public function getRaw();
4646

4747
/**
4848
* Escape a comparison string
49-
*
49+
*
5050
* @api
51-
*
51+
*
5252
* @param string $arg The unescaped string
53-
*
53+
*
5454
* @return string The escaped string
5555
*/
5656
public static function escape($arg);
@@ -59,19 +59,17 @@ public static function escape($arg);
5959
* encodes ComparisonString as string
6060
*
6161
* @api
62-
*
62+
*
6363
* @return string
6464
*/
6565
public function __toString();
6666

6767
/**
6868
* Serialize ComparisonString as JSON
69-
*
69+
*
7070
* @api
71-
*
71+
*
7272
* @return array
7373
*/
7474
public function jsonSerialize();
75-
7675
} // EOI
77-

0 commit comments

Comments
 (0)