Skip to content

Commit 5ebc1d1

Browse files
committed
feat: new app wide helper class
Signed-off-by: romanetar <roman_ag@hotmail.com>
1 parent 56325c7 commit 5ebc1d1

3 files changed

Lines changed: 10 additions & 14 deletions

File tree

app/Http/Utils/Filters/Filter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use App\Http\Utils\Filters\IQueryApplyable;
1717
use App\libs\Utils\PunnyCodeHelper;
18+
use App\Utils\Helpers;
1819
use Doctrine\ORM\QueryBuilder;
1920
use Illuminate\Support\Facades\Log;
2021
use Illuminate\Support\Facades\Validator;
@@ -504,7 +505,7 @@ private function convertValue($value, string $original_format)
504505
return self::convertToDateTime($value, $strTimeZone);
505506
break;
506507
case self::Boolean:
507-
return to_boolean($value) ? 1 : 0;
508+
return Helpers::to_boolean($value) ? 1 : 0;
508509
break;
509510
case self::Int:
510511
if (is_array($value)) {

app/Http/Utils/Filters/FilterElement.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php namespace utils;
2+
use App\Utils\Helpers;
3+
24
/**
35
* Copyright 2015 OpenStack Foundation
46
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -69,11 +71,11 @@ public function getBooleanValue(){
6971
if(is_array($this->value)){
7072
$res = [];
7173
foreach ($this->value as $val){
72-
$res[]= empty($val) ? '' : to_boolean($val);
74+
$res[]= empty($val) ? '' : Helpers::to_boolean($val);
7375
}
7476
return $res;
7577
}
76-
return to_boolean($this->value);
78+
return Helpers::to_boolean($this->value);
7779
}
7880

7981
public static function mapValueSymbols(string $val):string{
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?php
1+
<?php namespace App\Utils;
22
/*
3-
* Copyright 2023 OpenStack Foundation
3+
* Copyright 2025 OpenStack Foundation
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
@@ -12,15 +12,8 @@
1212
* limitations under the License.
1313
**/
1414

15-
if (!function_exists('to_boolean')) {
16-
17-
/**
18-
* Convert to boolean
19-
*
20-
* @param $booleable
21-
* @return boolean
22-
*/
23-
function to_boolean($booleable)
15+
final class Helpers {
16+
static function to_boolean($booleable)
2417
{
2518
return filter_var($booleable, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
2619
}

0 commit comments

Comments
 (0)