Overview

Namespaces

  • chippyash
    • Type
      • Exceptions
      • Interfaces
      • Number
        • Complex
        • Rational
      • String

Classes

  • AbstractMultiValueType
  • AbstractType
  • AbstractTypeFactory
  • BoolType
  • TypeFactory
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Hard type support
 4:  * For when you absolutely want to know what you are getting
 5:  *
 6:  * @author Ashley Kitson <akitson@zf4.biz>
 7:  * @copyright Ashley Kitson, UK, 2014
 8:  * @licence GPL V3 or later : http://www.gnu.org/licenses/gpl.html
 9:  */
10: 
11: namespace chippyash\Type;
12: 
13: /**
14:  * Boolean Type
15:  */
16: class BoolType extends AbstractType
17: {
18: 
19:     /**
20:      * Return correctly typed value for this type
21:      *
22:      * @param mixed $value
23:      *
24:      * @return boolean
25:      */
26:     protected function typeOf($value)
27:     {
28:         return (boolean) ($value);
29:     }
30: 
31:     /**
32:      * Magic method - convert to string
33:      *
34:      * @override
35:      * @return string
36:      */
37:     public function __toString()
38:     {
39:         $tmp = $this->get();
40:         return ($tmp ? 'true' : 'false');
41:     }
42: }
43: 
Chippyash Strong Types API documentation generated by ApiGen 2.8.0