@@ -34,11 +34,16 @@ class Hyphens
3434 *
3535 * @param string $isbn
3636 * @return string
37+ * @throws Exception
3738 */
3839 public function removeHyphens ($ isbn )
3940 {
40- $ isbn = str_replace (" " , "" , $ isbn );
41- $ isbn = str_replace ("- " , "" , $ isbn );
41+ if (is_string ($ isbn ) === false ) {
42+ throw new Exception ('Invalid parameter type. ' );
43+ }
44+
45+ $ isbn = str_replace (' ' , '' , $ isbn );
46+ $ isbn = str_replace ('- ' , '' , $ isbn );
4247 return $ isbn ;
4348 }
4449
@@ -49,7 +54,7 @@ public function removeHyphens($isbn)
4954 * @param string $char
5055 * @return string
5156 */
52- public function fixHyphens ($ isbn , $ char = " - " )
57+ public function fixHyphens ($ isbn , $ char = ' - ' )
5358 {
5459 $ isbn = $ this ->removeHyphens ($ isbn );
5560 return $ this ->addHyphens ($ isbn , $ char );
@@ -60,9 +65,15 @@ public function fixHyphens($isbn, $char = "-")
6065 *
6166 * @param string $isbn
6267 * @param string $char
68+ * @throws Exception
6369 */
64- public function addHyphens ($ isbn , $ char = " - " )
70+ public function addHyphens ($ isbn , $ char = ' - ' )
6571 {
72+ if (is_string ($ isbn ) === false ||
73+ is_string ($ char ) === false ) {
74+ throw new Exception ('Invalid parameter type. ' );
75+ }
76+
6677 $ this ->isbn = $ isbn ;
6778 $ this ->isbnSplit = array ();
6879
@@ -157,7 +168,7 @@ private function getRegistrantElement()
157168 if (isset ($ this ->isbnSplit [0 ]) === true ) {
158169 $ soFar = implode ('- ' , $ this ->isbnSplit );
159170 } else {
160- $ soFar = " 978- " .$ this ->isbnSplit [1 ];
171+ $ soFar = ' 978- ' .$ this ->isbnSplit [1 ];
161172 }
162173
163174 switch ($ soFar ) {
0 commit comments