How to use phpFloat class

Best Atoum code snippet using phpFloat

utils.php

Source:utils.php Github

copy

Full Screen

...140 }141 }142 143 static function sqlFloatToPHP($sqlFloat) {144 $phpFloat;145 if(!is_null($sqlFloat))146 {147 if (is_numeric($sqlFloat)) {148 $phpFloat = (float) $sqlFloat;149 }150 return $phpFloat;151 } 152 }153 154 static function postBoolToPHP($postBool) {155 $phpBool = null;156 157 if(strtolower( $postBool) == "true" || strtolower( $postBool) == "on")158 {159 return true;160 }161 162 if(strtolower( $postBool) == "false")163 {164 return false;165 }166 167 if(is_bool($postBool))168 {169 $phpBool = (bool)$postBool;170 171 }172 else 173 {174 if(is_numeric($postBool))175 {176 if(Utils::postIntToPHP($postBool)==0)177 {178 $phpBool = false;179 }180 else 181 {182 $phpBool = true;183 }184 185 }186 else 187 {188 throw new Exception("El parametro :" . $postBool . " no puede ser casteado a bool", 2010008);189 }190 191 192 193 }194 195 return $phpBool;196 }197 198 199 static function postIntToPHP($postInt) {200 $phpInt = null;201 $postInt = trim($postInt);202 if(is_numeric($postInt))203 {204 if(((float)$postInt) == ((int)$postInt))//TODO:esto indica que es entero no float?205 {206 $phpInt = (int)$postInt;207 }208 else 209 {210 throw new Exception("el parametro" . $postInt . " es flotante y debe ser entero", 2010006);211 }212 }213 else 214 {215 throw new Exception("El parametro:" . $postInt . " no es numerico");216 }217 return $phpInt;218 }219 220 static function postFloatToPHP($postFloat) {221 $phpFloat = null;222 223 if(is_numeric($postFloat))224 {225 $phpFloat = (float)($postFloat);226 }227 else 228 {229 throw new Exception("El parametro:" . $postFloat . " no es numerico", 2010007);230 231 }232 return $phpFloat;233 }234 235 236 //Convierte un int PHP en int SQL237 static function phpIntToSQL($phpInt) {238 $sqlInt = 'null'; //TODO: O deberia ser "null" ???239 if(isset($phpInt))240 {241 $sqlInt = "0";242 }243 if (!empty($phpInt)) {244 $sqlInt = (string) $phpInt;245 }246 247 248 return $sqlInt;249 }250 251 /**252 * 253 * Convierte un int php en un int HTML254 * @param int $phpInt255 */256 static function phpIntToHTML($phpInt) {257 $htmlInt ="";258 if($phpInt==0)259 $htmlInt="0";260 else 261 $htmlInt = $phpInt;262 263 if(!isset($phpInt))264 $htmlInt = "";265 266 return $htmlInt;267 }268 269 /**270 * 271 * Convierte un float php en un float HTML272 * @param float $phpFloat273 */274 static function phpFloatToHTML($phpFloat) {275 $html ="";276 if($phpFloat==0)277 $html="0.0";278 else 279 $html = $phpFloat;280 281 if(!isset($phpFloat))282 $html = "";283 284 return $html;285 }286 287 288 static function phpIntToHTMLCeroBase($phpInt) {289 $htmlInt ="0";290 if($phpInt==0)291 $htmlInt="0";292 else 293 $htmlInt = $phpInt;294 295 if(!isset($phpInt))296 $htmlInt = "0";297 298 return $htmlInt;299 }300 301 //Convierte un float PHP en int SQL302 static function phpFloatToSQL($phpfloat) {303 $sqlfloat = 'null'; //TODO: O deberia ser "null" ???304 if (!is_null($phpfloat)) {305 $sqlfloat = (string) $phpfloat;306 }307 308 return $sqlfloat;309 }310 311 312 //Convierte un date SQL en timestamp PHP (hora 00:00:00)313 static function sqlDateToPHPTimestamp($sqlDate) {314 $phpTimestamp = null;315 if (!empty($sqlDate)) {316 $anio = (int) substr($sqlDate, 0, 4); ...

Full Screen

Full Screen

GeoJSONController.php

Source:GeoJSONController.php Github

copy

Full Screen

1<?php2namespace App\Http\Controllers;3use Illuminate\Http\Request;4use App\Http\Requests;5use DateTime;6use DB;7use Illuminate\Support\Facades\Input;8use Auth;9class GeoJSONController extends Controller {10 // returns an array containing folder path as a string and number of json files11 public function getNumJSONFiles($jsonFolderPath) {12 $num_files = 0;13 $files = scandir($jsonFolderPath);14 $len = count($files);15 $pattern = ".json"; // pattern is chunk_<number>.json"16 $array = [$jsonFolderPath];17 for ($i = 0; $i < $len; $i++) {18 if (strpos($files[$i], $pattern) !== false) {19 $num_files++;20 }21 }22 array_push($array, $num_files);23 return $array;24 }25 private function postgresToPHPArray($pgArray) {26 $postgresStr = trim($pgArray, "{}");27 $elmts = explode(",", $postgresStr);28 $arrayToReturn = [];29 $arrayLen = count($elmts);30 for ($i = 0; $i < $arrayLen; $i++) {31 $curString = $elmts[$i]; 32 if (strpos($curString, "POLYGON") !== false) {33 $curString = substr($curString, 1);34 $curString = $curString . " " . $elmts[$i + 1];35 $curString = $curString . " " . $elmts[$i + 2];36 $curString = $curString . " " . $elmts[$i + 3];37 $curString = substr($curString, 0, strlen($curString) - 1);38 $i += 3;39 }40 array_push($arrayToReturn, $curString);41 }42 return $arrayToReturn;43 }44 private function stringArrayToFloatArray($array) { 45 return array_map("floatval", $array);46 }47 private function postgresToPHPFloatArray($pgArray) {48 $stringArray = $this->postgresToPHPArray($pgArray);49 return $this->stringArrayToFloatArray($stringArray);50 }51 /** @throws Exception */52 private function jsonDataForPoint($area, $pointNumber) {53 $json = [];54 // hard coded until zishi is back55 $decimal_dates = null;56 $string_dates = null;57 $query = "SELECT decimaldates, stringdates FROM area WHERE unavco_name=?";58 $dateInfos = DB::select($query, [$area]);59 foreach ($dateInfos as $dateInfo) {60 $decimal_dates = $dateInfo->decimaldates;61 $string_dates = $dateInfo->stringdates;62 }63 $json["decimal_dates"] = $this->postgresToPHPFloatArray($decimal_dates);64 $json["string_dates"] = $this->postgresToPHPArray($string_dates);65 $query = "SELECT *, st_astext(wkb_geometry) from " . $area . " where p = ?";66 $points = DB::select($query, [$pointNumber]);67 foreach ($points as $point) {68 $json["displacements"] = $this->postgresToPHPFloatArray($point->d);69 }70 return $json;71 }72 public function getDataForPoint($area, $pointNumber) {73 try {74 $json = $this->jsonDataForPoint($area, $pointNumber);75 echo json_encode($json);76 } catch (\Illuminate\Database\QueryException $e) {77 echo "Point Not found";78 }79 } 80public function getPoints() {81 $points = Input::get("points");82 try {83 $json = []; 84 $json["displacements"] = [];85 $decimal_dates = null;86 $string_dates = null;87 $parameters = explode("/", $points);88 $area = $parameters[0];89 $offset = count($parameters) - 2;90 $pointsArray = array_slice($parameters, 1, $offset);91 $pointsArrayLen = count($pointsArray);92 $query = "SELECT decimaldates, stringdates FROM area WHERE area.unavco_name like ?";93 $dateInfos = DB::select($query, [$area]);94 foreach ($dateInfos as $dateInfo) {95 $decimal_dates = $dateInfo->decimaldates;96 $string_dates = $dateInfo->stringdates;97 }98 $json["decimal_dates"] = $this->postgresToPHPFloatArray($decimal_dates);99 $json["string_dates"] = $this->postgresToPHPArray($string_dates);100 $query = "WITH points(point) AS (VALUES";101 for ($i = 0; $i < $pointsArrayLen - 1; $i++) { 102 $curPointNum = $pointsArray[$i];103 $query = $query . "(" . $curPointNum . "),"; 104 }105 // add last ANY values without comma106 $curPointNum = $pointsArray[$i];107 $query = $query . "(" . $curPointNum . ")) SELECT *, st_astext(wkb_geometry) from " . $area . " INNER JOIN points p ON (" . $area . ".p = p.point) ORDER BY p ASC";108 // echo $fullQuery;109 // echo $query;110 $points = DB::select($query);111 foreach ($points as $point) {112 $displacements = $this->postgresToPHPFloatArray($point->d);113 array_push($json["displacements"], $displacements);114 } 115 echo json_encode($json);116} catch (\Illuminate\Database\QueryException $e) {117 echo "Error Getting Points";118}119}120private function getExtraAttributesForAreas() {121 $sql = "SELECT * FROM extra_attributes";122 $attributes = DB::select($sql);123 $attributesDict = [];124 foreach ($attributes as $attribute) {125 $key = $attribute->attributekey;126 $value = $attribute->attributevalue;127 $attributesDict[$attribute->area_id][$key] = $value;128 }129 return $attributesDict;130}131public function getAreas() {132 $json = array();133 try {134 $query = "SELECT * from area";135 $areas = DB::select($query);136 $permissionController = new PermissionsController();137 $areasPermissions = $permissionController->getPermissions("area", "area_allowed_permissions", ["area.unavco_name = area_allowed_permissions.area_name"]);138 $userPermissions = NULL;139 // if we aren't logged in, our permission is public140 if (Auth::guest()) {141 $userPermissions = ["public"];142 } else {143 $userPermissions = $permissionController->getUserPermissions(Auth::id(), "users", "user_permissions", ["users.id = user_permissions.user_id"]);144 array_push($userPermissions, "public"); // every user must have public permissions145 }146 $extra_attributes = $this->getExtraAttributesForAreas();147 $json["areas"] = [];148 foreach ($areas as $area) {149 $unavco_name = $area->unavco_name;150 $project_name = $area->project_name;151 $currentArea = [];152 $currentArea["unavco_name"] = $unavco_name;153 $currentArea["project_name"] = $project_name;154 // do we have info for that area in the DB? if not, we assume it's public155 $curAreaPermissions = NULL;156 if (isset($areasPermissions[$unavco_name])) {157 $curAreaPermissions = $areasPermissions[$unavco_name];158 } else {159 $curAreaPermissions = ["public"];160 }161 foreach ($curAreaPermissions as $curAreaPermission) {162 if (in_array($curAreaPermission, $userPermissions)) {163 $currentArea["coords"]["latitude"] = $area->latitude;164 $currentArea["coords"]["longitude"] = $area->longitude; 165 $currentArea["num_chunks"] = $area->numchunks;166 $currentArea["country"] = $area->country;167 $currentArea["attributekeys"] = $this->postgresToPHPArray($area->attributekeys);168 $currentArea["attributevalues"] = $this->postgresToPHPArray($area->attributevalues);169 $currentArea["decimal_dates"] = $this->postgresToPHPFloatArray($area->decimaldates);170 $currentArea["region"] = $area->region;171 $bindings = [$area->id];172 if (isset($extra_attributes[$area->id])) {173 $currentArea["extra_attributes"] = $extra_attributes[$area->id];174 } else {175 $currentArea["extra_attributes"] = NULL;176 }177 array_push($json["areas"], $currentArea);178 continue;179 }180 }181 }182 echo json_encode($json);183 } catch (\Illuminate\Database\QueryException $e) {184 echo "error getting areas";185 }186}187 public function pointDataToTextFile($area, $pointNumber) {188 try {189 $json = $this->jsonDataForPoint($area, $pointNumber);190 $filePath = storage_path() . "/" . $area . ".txt";191 $textFile = fopen($filePath, "w") or die("failed");192 $dates = $json["string_dates"];193 $displacements = $json["displacements"];194 $datesLen = count($dates);195 $lineToWrite = "";196 for ($i = 0; $i < $datesLen; $i++) {197 $lineToWrite .= $dates[$i] . " " . $displacements[$i] . "\n";198 }199 fwrite($textFile, $lineToWrite);200 $response = response()->download($filePath)->deleteFileAfterSend(true);201 fclose($textFile);202 return $response;203 } catch (\Illuminate\Database\QueryException $e) {204 echo "Error getting point data for text file";205 return NULL;206 }207 }208}...

Full Screen

Full Screen

page_annonce_traite.php

Source:page_annonce_traite.php Github

copy

Full Screen

1<?php 2// Etablir la connexion à la base de donnée3require_once "php/connect.php";4// écriture de la déclaration SQL 5// Prendre les valeurs de tous les champs dans la table vetements à l'emplacement de l'id récupéré sur page_annonces.php ou page_index.php6$sql = "SELECT `id`, `img_chemin`, `titre`, `description`, `taille`, `sexe`, `style`, `visible` FROM `vetements` WHERE id = :id";7// préparation de la requête SQL8$stmt = $pdo->prepare($sql);9// on assigne la valeur du champ id de la table à la variable qu'on récupère dans l'URL10$stmt->bindValue(":id", $_GET['id']);11// On exécute la requête SQL12$stmt->execute();13?>14<!DOCTYPE html>15<html>16 <head>17 <meta charset="utf-8">18 <title>Annonce</title>19 <link rel="stylesheet" type="text/css" href="styles/styles.css">20 <link href="https://fonts.googleapis.com/css?family=Josefin+Sans:300,400,700|Raleway" rel="stylesheet">21 </head>22 <body>23 <?php 24 include_once "include/header.php";25 ?>26 <h2 class="h2">Toutes les annonces</h2>27 <?php28 // Stocker les informations de la table pour l'élément dans un tableau associatif $row29 while($row = $stmt->fetch(PDO::FETCH_ASSOC)):30 // Si on bidouille la valeur de visible, on nous retourne vers la page annonces (évite aux visiteurs d'accéder à des articles non visibles)31 if ($row['visible'] != 1) {32 header('Location: page_annonces.php');33 // Si l'élément cliqué est bien "visible = 1" dans la BDD, afficher les informations de l'éléments34 } else { ?>35 <div class="wfull clearfix">36 <figure>37 <img src="img-content/<?=$row['img_chemin']?>" alt="">38 </figure>39 <div class="text">40 <h3><?= $row["titre"]?></h3>41 <p><?= $row["description"]?></p>42 <p class="phpfloat">Taille : <?= $row["taille"]?></p>43 <p class="phpfloat">Sexe : <?= $row["sexe"]?></p>44 <p>Style : <?= $row["style"]?></p> 45 <a href="#" id="boutonvalider">Je veux !</a>46 </div>47 </div>48 <?php }49 endwhile;50 include_once "include/footer.php";51 ?>52 </body>53</html>...

Full Screen

Full Screen

phpFloat

Using AI Code Generation

copy

Full Screen

1require_once 'phpFloat.php';2$phpFloat = new phpFloat();3echo $phpFloat->addition(1,1);4echo $phpFloat->subtraction(1,1);5echo $phpFloat->multiplication(1,1);6echo $phpFloat->division(1,1);7echo $phpFloat->power(1,1);8echo $phpFloat->modulus(1,1);9echo $phpFloat->squareRoot(1);10echo $phpFloat->absoluteValue(1);11echo $phpFloat->rounding(1);12echo $phpFloat->roundingUp(1);13echo $phpFloat->roundingDown(1);14echo $phpFloat->roundingHalfUp(1);15echo $phpFloat->roundingHalfDown(1);16echo $phpFloat->roundingHalfEven(1);17echo $phpFloat->roundingHalfOdd(1);18echo $phpFloat->roundingHalfToEven(1);19echo $phpFloat->roundingHalfToOdd(1);20echo $phpFloat->roundingHalfToZero(1);21echo $phpFloat->roundingHalfAwayFromZero(1);22echo $phpFloat->roundingHalfToNegativeInfinity(1);23echo $phpFloat->roundingHalfToPositiveInfinity(1);24echo $phpFloat->roundingToNegativeInfinity(1);25echo $phpFloat->roundingToPositiveInfinity(1);26echo $phpFloat->roundingToZero(1);27echo $phpFloat->roundingAwayFromZero(1);28echo $phpFloat->roundingToNearest(1);29echo $phpFloat->roundingToNearest(1

Full Screen

Full Screen

phpFloat

Using AI Code Generation

copy

Full Screen

1$phpFloat = new \Atoum\phpFloat();2$phpFloat->add(0.1, 0.2);3$phpFloat = new \Atoum\phpFloat();4$phpFloat->add(0.1, 0.2);5$phpFloat = new \Atoum\phpFloat();6$phpFloat->add(0.1, 0.2);7namespace Atoum;8{9 public function add($a, $b)10 {11 return $a + $b;12 }13}

Full Screen

Full Screen

phpFloat

Using AI Code Generation

copy

Full Screen

1require_once('phpFloat.php');2$phpFloat = new phpFloat();3echo $phpFloat->add(1.1, 1.1);4require_once('phpFloat.php');5$phpFloat = new phpFloat();6echo $phpFloat->add(1.1, 1.1);7require_once('phpFloat.php');8$phpFloat = new phpFloat();9echo $phpFloat->add(1.1, 1.1);10require_once('phpFloat.php');11$phpFloat = new phpFloat();12echo $phpFloat->add(1.1, 1.1);13require_once('phpFloat.php');14$phpFloat = new phpFloat();15echo $phpFloat->add(1.1, 1.1);16require_once('phpFloat.php');17$phpFloat = new phpFloat();18echo $phpFloat->add(1.1, 1.1);19require_once('phpFloat.php');20$phpFloat = new phpFloat();21echo $phpFloat->add(1.1, 1.1);22require_once('phpFloat.php');23$phpFloat = new phpFloat();24echo $phpFloat->add(1.1, 1.1);25require_once('phpFloat.php');26$phpFloat = new phpFloat();27echo $phpFloat->add(1.1, 1.1);28require_once('phpFloat.php');29$phpFloat = new phpFloat();

Full Screen

Full Screen

phpFloat

Using AI Code Generation

copy

Full Screen

1require_once 'vendor/autoload.php';2use atoum\phpfloat as phpFloat;3$myFloat = new phpFloat\phpFloat();4$myFloat->setFloat(10.5);5echo $myFloat->getFloat();6$myFloat->setFloat(10.5);7$myFloat->addFloat(10.5);8echo $myFloat->getFloat();9$myFloat->setFloat(10.5);10$myFloat->subtractFloat(10.5);11echo $myFloat->getFloat();12$myFloat->setFloat(10.5);13$myFloat->multiplyFloat(10.5);14echo $myFloat->getFloat();15$myFloat->setFloat(10.5);16$myFloat->divideFloat(10.5);17echo $myFloat->getFloat();18$myFloat->setFloat(10.5);19$myFloat->roundFloat();20echo $myFloat->getFloat();21$myFloat->setFloat(10.5);22$myFloat->roundFloat(1);23echo $myFloat->getFloat();24$myFloat->setFloat(10.5);25$myFloat->ceilFloat();26echo $myFloat->getFloat();27$myFloat->setFloat(10.5);28$myFloat->floorFloat();29echo $myFloat->getFloat();30$myFloat->setFloat(10.5);31$myFloat->absFloat();32echo $myFloat->getFloat();

Full Screen

Full Screen

phpFloat

Using AI Code Generation

copy

Full Screen

1require_once 'phpFloat.php';2$phpFloat = new phpFloat();3$phpFloat->add(2.3, 3.4);4echo $phpFloat->getResult();5$phpFloat->add(2.3, 3.4);6echo $phpFloat->getResult();7$phpFloat->add(2.3, 3.4);8echo $phpFloat->getResult();9$phpFloat->add(2.3, 3.4);10echo $phpFloat->getResult();11$phpFloat->add(2.3, 3.4);12echo $phpFloat->getResult();13$phpFloat->add(2.3, 3.4);14echo $phpFloat->getResult();15$phpFloat->add(2.3, 3.4);16echo $phpFloat->getResult();17$phpFloat->add(2.3, 3.4);18echo $phpFloat->getResult();19$phpFloat->add(2.3, 3.4);20echo $phpFloat->getResult();21$phpFloat->add(2.3, 3.4);22echo $phpFloat->getResult();

Full Screen

Full Screen

phpFloat

Using AI Code Generation

copy

Full Screen

1require_once 'atoum.php';2$float = new phpFloat();3$float->floatValue(0.5);4echo $float->result;5require_once 'atoum.php';6$float = new phpFloat();7$float->floatValue(0.5);8echo $float->result;9require_once 'atoum.php';10$float = new phpFloat();11$float->floatValue(0.5);12echo $float->result;13require_once 'atoum.php';14$float = new phpFloat();15$float->floatValue(0.5);16echo $float->result;17require_once 'atoum.php';18$float = new phpFloat();19$float->floatValue(0.5);20echo $float->result;21require_once 'atoum.php';22$float = new phpFloat();23$float->floatValue(0.5);24echo $float->result;25require_once 'atoum.php';26$float = new phpFloat();27$float->floatValue(0.5);28echo $float->result;

Full Screen

Full Screen

phpFloat

Using AI Code Generation

copy

Full Screen

1require_once 'phpFloat.php';2$phpFloat = new phpFloat();3$phpFloat->FloatToString(-123456789.123456789);4$phpFloat->StringToFloat('-123456789.123456789');5$phpFloat->FloatToString(123456789.123456789);6$phpFloat->StringToFloat('123456789.123456789');7$phpFloat->FloatToString(0.123456789);8$phpFloat->StringToFloat('0.123456789');9$phpFloat->FloatToString(-0.123456789);10$phpFloat->StringToFloat('-0.123456789');11$phpFloat->FloatToString(0.0);12$phpFloat->StringToFloat('0.0');13$phpFloat->FloatToString(-0.0);14$phpFloat->StringToFloat('-0.0');15$phpFloat->FloatToString(123456789.0);16$phpFloat->StringToFloat('123456789.0');17$phpFloat->FloatToString(-123456789.0);18$phpFloat->StringToFloat('-123456789.0');19$phpFloat->FloatToString(123456789.123456789);20$phpFloat->StringToFloat('123456789.123456789');21$phpFloat->FloatToString(-123456789.123456789);

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful