Skip to content

Commit

Permalink
GITBOOK-3: No subject
Browse files Browse the repository at this point in the history
  • Loading branch information
d8vjork authored and gitbook-bot committed Feb 16, 2025
1 parent 6e19f94 commit 608c5a6
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
* [Helpers](function-helpers.md)
* [Commands](commands.md)
* [Middleware](middleware.md)
* [Facades](facades.md)
16 changes: 16 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,19 @@ Check and list all the config and publishable group that is outdated on your app
```bash
php artisan vendor:check
```

### Get dependencies licenses list

Gets licenses list from backend and frontend dependencies (using NPM).

```sh
php artisan vendor:licenses
```

You can get Markdown or JSON formatted list by using the option `--format`

```bash
php artisan vendor:licenses --format=markdown

php artisan vendor:licenses --format=json
```
147 changes: 147 additions & 0 deletions docs/facades.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
---
description: This package extends Laravel's framework facades with new useful methods.
---

# Facades

### Arr

#### exceptValues

Filter array shorthand by just excluding the values passed as second argument.

```php
Arr::exceptValues([
"hello" => "world",
"foo" => "bar"
], "bar");

// ["hello" => "world"]
```

#### onlyValues

Filter array shorthand by just including the values passed as second argument.

```php
Arr::onlyValues([
"hello" => "world",
"foo" => "bar"
], "world");

// ["hello" => "world"]
```

#### query

Write a URL query string from an array.

```php
Arr::query([
"q" => "this",
"param2" => "value"
], "world");

// "?q=this&param2=value"
```

### Collection

#### toCsv

Converts collection of items to CSV with its headers.

```php
collect([
[
"name" => "Ruben Robles",
"role" => "Admin"
],
[
"name" => "Taylor Otwell",
"role" => "Admin"
]
])->toCsv(); // "name,role\nRuben Robles,Admin\nTaylor Otwell,Admin"
```

#### templateJoin

Join items of the collection using a template substitution.

```php
collect([
[
"name" => "Ruben Robles",
"email" => "[email protected]"
],
[
"name" => "Taylor Otwell",
"email" => "[email protected]"
]
])->templateJoin(":name (:email)"); // "Ruben Robles ([email protected]), Taylor Otwell ([email protected])"
```

### Number

#### toShort

Get shorter version of a big number if possible.

```php
Number::toShort(1000); // "1K"
Number::toShort(2200); // "2,2K"
```

#### toByteUnit

Get byte unit version of a number.

```php
Number::toByteUnit(1000)->toKB(); // "1.00 KB"
```

## Storage

#### humanSize

Get human readable file size at given path.

```php
use OpenSoutheners\ByteUnitConverter\MetricSystem;

Storage::humanSize("path/file.png"); // "124.00 KB"
Storage::humanSize("path/file.png", MetricSystem::KiB); // "121.09 KiB"
```

### Str

#### parseQuery

Parse a URL query string into an array.

```php
Str::parseQuery("?q=search&param1=value"); // ["q" => "search", "param1" => "value"]

Str::of("?q=search&param1=value")->parseQuery();
```

#### isJsonStructure

Check if string contains a valid JSON structure.

```php
Str::isJsonStructure('{"foo": "bar"}'); // true

Str::of('"bar"')->isJsonStructure(); // false
```

#### emailDomain

Get domain part from email address.

```php
Str::emailDomain("[email protected]"); // "example.com"

Str::of("[email protected]")->emailDomain(); // "laravel.com"
```

0 comments on commit 608c5a6

Please sign in to comment.