Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for sync #1

Merged
merged 9 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 87 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,151 +22,151 @@ composer require stepanenko3/laravel-helpers
Included functions:

```php
apply_condition(string|int|float $amount, string|null $conditionValue = null): float
apply_condition(string|int|float $amount, string|null $conditionValue = null): float

camel_to_snake_case(string $input): string
camel_to_snake_case(string $input): string

carbon(string|null $parseString = '', string $tz = null): Carbon
carbon(string|null $parseString = '', string $tz = null): Carbon

class_basename(mixed $class): ?string
class_basename(mixed $class): ?string

class_by_key(string $key, string $service = 'Models'): ?string
class_by_key(string $key, string $service = 'Models'): ?string

cleanConditionValue(string|array $value): string|array
cleanConditionValue(string|array $value): string|array

closetags(string $html): string
closetags(string $html): string

condition_value(string|int|float $amount, string|null $conditionValue = null): string|int|float
condition_value(string|int|float $amount, string|null $conditionValue = null): string|int|float

contrast_color(string $hexColor): string
contrast_color(string $hexColor): string

distance(
string|float|int $latitudeFrom,
string|float|int $longitudeFrom,
string|float|int $latitudeTo,
string|float|int $longitudeTo,
int $earthRadius = 6371000
): float|int
distance(
string|float|int $latitudeFrom,
string|float|int $longitudeFrom,
string|float|int $latitudeTo,
string|float|int $longitudeTo,
int $earthRadius = 6371000
): float|int

domain(): string
domain(): string

dots_to_camel_case(
string $string,
bool $capitalizeFirstCharacter = false
): string
dots_to_camel_case(
string $string,
bool $capitalizeFirstCharacter = false
): string

formatMemory(
float $size,
int $level = 0,
int $precision = 2,
int $base = 1024,
bool $asArray = false
): string|array
formatMemory(
float $size,
int $level = 0,
int $precision = 2,
int $base = 1024,
bool $asArray = false
): string|array

format_weight(float|int|string $weight): string
format_weight(float|int|string $weight): string

from_timestamp(string|int $timestamp): Carbon
from_timestamp(string|int $timestamp): Carbon

get_ascii_key(string $needle, array $haystack = []): ?int
get_ascii_key(string $needle, array $haystack = []): ?int

getAspectRatio(int $width, int $height): string
getAspectRatio(int $width, int $height): string

get_by_ascii(string $needle, array $haystack = []): mixed
get_by_ascii(string $needle, array $haystack = []): mixed

get_initials(string $name): array|string|null
get_initials(string $name): array|string|null

get_ip(): string
get_ip(): string

get_order_id(string|int $id): string
get_order_id(string|int $id): string

get_query_raw(EloquentBuilder|QueryBuilder $builder): string
get_query_raw(EloquentBuilder|QueryBuilder $builder): string

hashid_decode(string|int $id): array
hashid_decode(string|int $id): array

hashid_encode(string|int $id): string
hashid_encode(string|int $id): string

in_array_wildcard(mixed $needle, array $haystack): bool
in_array_wildcard(mixed $needle, array $haystack): bool

ipv4_in_range(mixed $ip, array|string $range): bool
ipv4_in_range(mixed $ip, array|string $range): bool

ipv4_match_mask(string $ip, string $network): bool
ipv4_match_mask(string $ip, string $network): bool

is_day(
string|int|null $timestamp = null,
float $lat = 50.458124677588046,
float $lng = 30.51755711378018
): bool
is_day(
string|int|null $timestamp = null,
float $lat = 50.458124677588046,
float $lng = 30.51755711378018
): bool

is_digit(mixed $value): bool
is_digit(mixed $value): bool

is_night(
string|int|null $timestamp = null,
float $lat = 50.458124677588046,
float $lng = 30.51755711378018
): bool
is_night(
string|int|null $timestamp = null,
float $lat = 50.458124677588046,
float $lng = 30.51755711378018
): bool

is_query_joined(EloquentBuilder|QueryBuilder $query, string $table): bool
is_query_joined(EloquentBuilder|QueryBuilder $query, string $table): bool

key_by_class(mixed $class): ?string
key_by_class(mixed $class): ?string

mb_lcfirst(string $string): string
mb_lcfirst(string $string): string

mb_pathinfo(string $path, string $opt = ''): array|string
mb_pathinfo(string $path, string $opt = ''): array|string

mb_ucfirst(string $string): string
mb_ucfirst(string $string): string

model_by_key(string $key): ?string
model_by_key(string $key): ?string

normalizePrice(string|int|float $price): float
normalizePrice(string|int|float $price): float

number(string|int|float $value, null|int $decimals = 0): string
number(string|int|float $value, null|int $decimals = 0): string

num_pad(string|int $value, int $length = 8): string
num_pad(string|int $value, int $length = 8): string

plural_text(string $text, string $endings): string
plural_text(string $text, string $endings): string

// Example usage: str_plural_ru('черновик', 2, '|а|ов'); # Return: черновика
plural_word(string $word, int $count, string $endings): string
// Example usage: str_plural_ru('черновик', 2, '|а|ов'); # Return: черновика
plural_word(string $word, int $count, string $endings): string

remove_query_param(string $url, string $param): string
remove_query_param(string $url, string $param): string

renderBlade(string $string, array|null $data = null): false|string
renderBlade(string $string, array|null $data = null): false|string

rglob(string $pattern): array|false
rglob(string $pattern): array|false

seo_replace(string $str, array $attributes = []): string
seo_replace(string $str, array $attributes = []): string

storage_url(string $path, string|null $disk = null): string
storage_url(string $path, string|null $disk = null): string

str_contains(string $haystack, array $needles): bool
str_contains(string $haystack, array $needles): bool

toggle_url(
string $key,
string|null $value = null,
string|null $url = null
): string
toggle_url(
string $key,
string|null $value = null,
string|null $url = null
): string

translit_to_ua(string $text): string
translit_to_ua(string $text): string

truncate_html(string $text, int $length = 100, array $options = []): string
truncate_html(string $text, int $length = 100, array $options = []): string

url_data(string $string, string $action = 'encrypt'): bool|string
url_data(string $string, string $action = 'encrypt'): bool|string

user(): \App\Models\User
user()

utf8ize(array|string $d): string
utf8ize(array|string $d): string

uuid(int $version = 6): string
uuid(int $version = 6): string

validateDate(string $date, string $format = 'Y-m-d'): bool
validateDate(string $date, string $format = 'Y-m-d'): bool

valueIsPercentage(string $value): bool
valueIsPercentage(string $value): bool

valueIsToBeAdded(string $value): bool
valueIsToBeAdded(string $value): bool

valueIsToBeSubtracted(string $value): bool
valueIsToBeSubtracted(string $value): bool

youtube_id(string $url): string
youtube_id(string $url): string
```

## Credits
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"php": ">=8.0",
"ext-json": "*",
"ext-openssl": "*",
"laravel/framework": "^9.0",
"hashids/hashids": "^4.1",
"laravel/framework": "^9.0",
"laravel/pint": "^1.2",
"ramsey/uuid": "^4.0"
},
"autoload": {
Expand Down
31 changes: 31 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"preset": "laravel",
"rules": {
"concat_space": {
"spacing": "one"
},
"group_import": true,
"single_import_per_statement": false,
"no_space_around_double_colon": true,
"types_spaces": {
"space": "single"
},
"operator_linebreak": {
"position": "beginning"
},
"single_quote": {
"strings_containing_single_quote_chars": true
},
"blank_line_before_statement": {
"statements": [
"break",
"continue",
"declare",
"return",
"throw",
"try"
]
},
"not_operator_with_successor_space": false
}
}
Loading