protected function build($dbMode, $pdo = null)
 {
     if ($pdo === null) {
         // Don't do this
         return null;
     }
     $db = DB::get();
     // Get rules
     $rules = array();
     $stmt = $pdo->prepare("SELECT * FROM PAYMENTMODES_RETURNS " . "WHERE PAYMENTMODE_ID = :id ORDER BY MIN ASC");
     $stmt->bindParam(":id", $dbMode['ID']);
     $stmt->execute();
     while ($row = $stmt->fetch()) {
         $rules[] = new PaymentModeReturn($row['MIN'], $row['RETURNMODE_ID']);
     }
     // Get values
     $values = array();
     $stmtVal = $pdo->prepare("SELECT * FROM PAYMENTMODES_VALUES " . "WHERE PAYMENTMODE_ID = :id ORDER BY DISPORDER ASC");
     $stmtVal->bindParam(":id", $dbMode['ID']);
     $stmtVal->execute();
     while ($row = $stmtVal->fetch()) {
         $values[] = new PaymentModeValue($row['VALUE'], $row['RESOURCE'], $row['DISPORDER']);
     }
     // Build
     $mode = PaymentMode::__build($dbMode['ID'], $dbMode['CODE'], $dbMode['NAME'], $dbMode['BACKNAME'], $dbMode['FLAGS'], $dbMode['IMAGE'] !== null, $rules, $values, $db->readBool($dbMode['ACTIVE']), $db->readBool($dbMode['SYSTEM']), $dbMode['DISPORDER']);
     return $mode;
 }
 /** @depends testConstruct */
 public function testBuild()
 {
     $rules = array(new PaymentModeReturn(0.0, 1), new PaymentModeReturn(1.0, 2));
     $values = array(new PaymentModeValue(10, "label_10", 1), new PaymentModeValue(20, "label_20", 2));
     $mode = PaymentMode::__build(1, "code", "label", "backLabel", PaymentMode::CUST_ASSIGNED, false, $rules, $values, true, false, true, 1);
     $this->assertEquals(1, $mode->id);
     $this->assertEquals("code", $mode->code);
 }