Exemple #1
0
 public function testCorrectUsage()
 {
     newType(FilePath::class, 'string');
     $path = new FilePath('foobar');
     $this->assertEquals('foobar', $path->unbox());
     newType(Age::class, 'int');
     $age = new Age(16);
     $this->assertEquals(16, $age->unbox());
     newType(Opacity::class, 'float');
     $opacity = new Opacity(0.75);
     $this->assertEquals(0.75, $opacity->unbox());
     newType(UltraBoolean::class, 'bool');
     $ultraBool = new UltraBoolean(EXTREMELY_TRUE);
     $this->assertEquals(EXTREMELY_TRUE, $ultraBool->unbox());
     newType(MegaObject::class, \StdClass::class);
     $inferiorObj = (object) [];
     $megaObj = new MegaObject($inferiorObj);
     $this->assertEquals($inferiorObj, $megaObj->unbox());
     // note explicit leading slash
     newType(SuperMegaObject::class, '\\StdClass');
     $superMegaObj = new SuperMegaObject($inferiorObj);
     $this->assertEquals($inferiorObj, $superMegaObj->unbox());
     newType('\\UltraMegaObject', \StdClass::class);
     $ultraMegaObj = new \UltraMegaObject($inferiorObj);
     $this->assertEquals($inferiorObj, $ultraMegaObj->unbox());
 }
 public function getPatientBMIForAgeGraphDataByPid($pid)
 {
     $data = array();
     $dob = $this->patient->getPatientDOBByPid($pid);
     foreach ($this->encounter->getVitalsByPid($pid) as $foo) {
         $fo['age'] = Age::getMonsBetweenDates($dob, $foo['date']) + 0.5;
         $fo['PP'] = $foo['bmi'];
         $data[] = $fo;
     }
     return $data;
 }
Exemple #3
0
<?php

class Age
{
    public static function get($format, $date, $timezone)
    {
        $tz = new DateTimeZone($timezone);
        $age = DateTime::createFromFormat($format, $date, $tz)->diff(new DateTime('now', $tz))->y;
        return $age;
    }
}
echo Age::get('Y/m/d', '1992/12/31', 'UTC');
 private function getAge()
 {
     $object = new Age();
     if ($object->getUserAge()) {
         $this->age = $object->getAge();
         return true;
     }
     return false;
 }