Skip to content

Commit 5b4c327

Browse files
committed
IncorrectValueTypeException
1 parent cc8c017 commit 5b4c327

File tree

13 files changed

+74
-27
lines changed

13 files changed

+74
-27
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* @author Rafal Przetakowski <[email protected]>
4+
* @copyright: (c) 2017 Beeflow Ltd
5+
*
6+
* Date: 11.04.17 17:31
7+
*/
8+
9+
namespace Beeflow\SQLQueryManager\Exception;
10+
11+
12+
class IncorrectValueTypeException extends \Exception
13+
{
14+
15+
}

Lib/Vartypes/BFBoolean.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
namespace Beeflow\SQLQueryManager\Lib\Vartypes;
2020

21+
use Beeflow\SQLQueryManager\Exception\IncorrectValueTypeException;
22+
2123
/**
2224
* @author Rafal Przetakowski <[email protected]>
2325
*/
@@ -60,15 +62,16 @@ public function __toString()
6062
/**
6163
* @param $value
6264
*
63-
* @throws \Exception
65+
* @return $this
66+
* @throws IncorrectValueTypeException
6467
*/
6568
public function setValue($value)
6669
{
6770
$val = (boolean)$value;
6871
if (gettype($val) == 'boolean') {
6972
$this->value = $val;
7073
} else {
71-
throw new \Exception('Value must be ' . __CLASS__ . ' type but is ' . gettype($val));
74+
throw new IncorrectValueTypeException('Value must be ' . __CLASS__ . ' type but is ' . gettype($val));
7275
}
7376

7477
return $this;

Lib/Vartypes/BFByte.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
namespace Beeflow\SQLQueryManager\Lib\Vartypes;
1919

20+
use Beeflow\SQLQueryManager\Exception\IncorrectValueTypeException;
21+
2022
/**
2123
* @author Rafal Przetakowski <[email protected]>
2224
*/
@@ -58,15 +60,16 @@ public function __toString()
5860
/**
5961
* @param $value
6062
*
61-
* @throws \Exception
63+
* @return $this
64+
* @throws IncorrectValueTypeException
6265
*/
6366
public function setValue($value)
6467
{
6568
$value = (integer)$value;
6669
if (isset($value) && in_array($value, array(0, 1))) {
6770
$this->value = $value;
6871
} else {
69-
throw new \Exception('Value must be ' . __CLASS__ . ' type but is ' . gettype($value));
72+
throw new IncorrectValueTypeException('Value must be ' . __CLASS__ . ' type but is ' . gettype($value));
7073
}
7174

7275
return $this;

Lib/Vartypes/BFDate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function __toString()
102102
/**
103103
* @param $value
104104
*
105-
* @throws \Exception
105+
* @return $this
106106
*/
107107
public function setValue($value)
108108
{

Lib/Vartypes/BFDouble.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
namespace Beeflow\SQLQueryManager\Lib\Vartypes;
2020

21+
use Beeflow\SQLQueryManager\Exception\IncorrectValueTypeException;
22+
2123
/**
2224
* @author Rafal Przetakowski <[email protected]>
2325
*/
@@ -30,12 +32,11 @@ class BFDouble implements VartypeInterface
3032
*/
3133
private $value;
3234

35+
3336
/**
37+
* BFDouble constructor.
3438
*
35-
* @param Mixed $val
36-
* @param $lenght ilość miejsc po przecinku
37-
*
38-
* @throws \Exception
39+
* @param null $val
3940
*/
4041
public function __construct($val = null)
4142
{
@@ -61,7 +62,8 @@ public function __toString()
6162
/**
6263
* @param $val
6364
*
64-
* @throws \Exception
65+
* @return $this
66+
* @throws IncorrectValueTypeException
6567
*/
6668
public function setValue($val)
6769
{
@@ -70,7 +72,7 @@ public function setValue($val)
7072
if (gettype($val) == 'double') {
7173
$this->value = $val;
7274
} else {
73-
throw new \Exception('Value must be ' . __CLASS__ . ' type but is ' . gettype($val) . ' - ' . $val);
75+
throw new IncorrectValueTypeException('Value must be ' . __CLASS__ . ' type but is ' . gettype($val) . ' - ' . $val);
7476
}
7577

7678
return $this;

Lib/Vartypes/BFEmail.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
namespace Beeflow\SQLQueryManager\Lib\Vartypes;
2020

21+
use Beeflow\SQLQueryManager\Exception\IncorrectValueTypeException;
22+
2123
/**
2224
* @author Rafal Przetakowski <[email protected]>
2325
*/
@@ -57,12 +59,13 @@ public function __toString()
5759
/**
5860
* @param $value
5961
*
60-
* @throws \Exception
62+
* @return $this
63+
* @throws IncorrectValueTypeException
6164
*/
6265
public function setValue($value)
6366
{
6467
if (!preg_match($this->regexp, $value)) {
65-
throw new \Exception('Value must be correct ' . __CLASS__ . ' type.');
68+
throw new IncorrectValueTypeException('Value must be correct ' . __CLASS__ . ' type.');
6669
} else {
6770
$this->value = $value;
6871
}

Lib/Vartypes/BFFloat.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
namespace Beeflow\SQLQueryManager\Lib\Vartypes;
2020

21+
use Beeflow\SQLQueryManager\Exception\IncorrectValueTypeException;
22+
2123
/**
2224
* @author Rafal Przetakowski <[email protected]>
2325
*/
@@ -70,7 +72,8 @@ public function __toString()
7072
/**
7173
* @param $value
7274
*
73-
* @throws \Exception
75+
* @return $this
76+
* @throws IncorrectValueTypeException
7477
*/
7578
public function setValue($value)
7679
{
@@ -79,7 +82,7 @@ public function setValue($value)
7982
if (gettype($value) == 'float') {
8083
$this->value = $value;
8184
} else {
82-
throw new \Exception('Value must be ' . __CLASS__ . ' type but is ' . gettype($value) . ' - ' . $value);
85+
throw new IncorrectValueTypeException('Value must be ' . __CLASS__ . ' type but is ' . gettype($value) . ' - ' . $value);
8386
}
8487

8588
return $this;

Lib/Vartypes/BFInteger.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
namespace Beeflow\SQLQueryManager\Lib\Vartypes;
2020

21+
use Beeflow\SQLQueryManager\Exception\IncorrectValueTypeException;
22+
2123
/**
2224
* @author Rafal Przetakowski <[email protected]>
2325
*/
@@ -60,15 +62,16 @@ public function __toString()
6062
/**
6163
* @param $value
6264
*
63-
* @throws \Exception
65+
* @return $this
66+
* @throws IncorrectValueTypeException
6467
*/
6568
public function setValue($value)
6669
{
6770
$value = (integer)$value;
6871
if (isset($value)) {
6972
$this->value = $value;
7073
} else {
71-
throw new \Exception('Value must be ' . __CLASS__ . ' type but is ' . gettype($value));
74+
throw new IncorrectValueTypeException('Value must be ' . __CLASS__ . ' type but is ' . gettype($value));
7275
}
7376

7477
return $this;

Lib/Vartypes/BFNip.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
namespace Beeflow\SQLQueryManager\Lib\Vartypes;
2020

21+
use Beeflow\SQLQueryManager\Exception\IncorrectValueTypeException;
22+
2123
/**
2224
* nip - polish vat no
2325
* if you want to check european vat no, see:
@@ -68,13 +70,14 @@ public function __toString()
6870
/**
6971
* @param $value
7072
*
71-
* @throws \Exception
73+
* @return $this
74+
* @throws IncorrectValueTypeException
7275
*/
7376
public function setValue($value)
7477
{
7578
$value = str_replace('-', '', $value);
7679
if (strlen($value) <> 10) {
77-
throw new \Exception('Value must be correct ' . __CLASS__ . ' type');
80+
throw new IncorrectValueTypeException('Value must be correct ' . __CLASS__ . ' type');
7881
}
7982

8083
$wagi = '657234567';
@@ -87,7 +90,7 @@ public function setValue($value)
8790
if ((integer)$value[9] == ($suma % 11)) {
8891
$this->value = $value;
8992
} else {
90-
throw new \Exception('Value must be correct ' . __CLASS__ . ' type');
93+
throw new IncorrectValueTypeException('Value must be correct ' . __CLASS__ . ' type');
9194
}
9295

9396
return $this;

Lib/Vartypes/BFPsqlSecureString.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
namespace Beeflow\SQLQueryManager\Lib\Vartypes;
2020

21+
use Beeflow\SQLQueryManager\Exception\IncorrectValueTypeException;
22+
2123
/**
2224
* Class BFPsqlSecureString
2325
*
@@ -66,7 +68,8 @@ public function __toString()
6668
/**
6769
* @param $value
6870
*
69-
* @throws \Exception
71+
* @return $this
72+
* @throws IncorrectValueTypeException
7073
*/
7174
public function setValue($value)
7275
{
@@ -91,7 +94,7 @@ public function setValue($value)
9194
if (gettype($value) == 'string') {
9295
$this->value = $value;
9396
} else {
94-
throw new \Exception('Value must be ' . __CLASS__ . ' type but is ' . gettype($value));
97+
throw new IncorrectValueTypeException('Value must be ' . __CLASS__ . ' type but is ' . gettype($value));
9598
}
9699

97100
return $this;

0 commit comments

Comments
 (0)