Skip to content

Commit 3ad00cb

Browse files
Rafal PrzetakowskiRafal Przetakowski
authored andcommitted
Byte vartype added
1 parent 99a8a72 commit 3ad00cb

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

Vartypes/BFByte.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
/**
4+
* GNU General Public License (Version 2, June 1991)
5+
*
6+
* This program is free software; you can redistribute
7+
* it and/or modify it under the terms of the GNU
8+
* General Public License as published by the Free
9+
* Software Foundation; either version 2 of the License,
10+
* or (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will
13+
* be useful, but WITHOUT ANY WARRANTY; without even the
14+
* implied warranty of MERCHANTABILITY or FITNESS FOR A
15+
* PARTICULAR PURPOSE. See the GNU General Public License
16+
* for more details.
17+
*/
18+
namespace Beeflow\SQLQueryManager\Vartypes;
19+
20+
/**
21+
* @author Rafal Przetakowski <[email protected]>
22+
*/
23+
class BFByte
24+
{
25+
/**
26+
*
27+
* @var Mixed
28+
*/
29+
private $value;
30+
31+
/**
32+
*
33+
* @param Mixed $value
34+
*
35+
* @throws \Exception
36+
*/
37+
public function __construct($value)
38+
{
39+
$value = (integer)$value;
40+
if (isset($value) && in_array($value, array(0, 1))) {
41+
$this->value = $value;
42+
} else {
43+
throw new \Exception('Value must be ' . __CLASS__ . ' type but is ' . gettype($value));
44+
}
45+
}
46+
47+
public function val()
48+
{
49+
return $this->__toString();
50+
}
51+
52+
/**
53+
*
54+
* @return Mixed
55+
*/
56+
public function __toString()
57+
{
58+
return (integer)$this->value;
59+
}
60+
}

0 commit comments

Comments
 (0)