Skip to content

Commit

Permalink
finishing up docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsizemore committed Mar 4, 2024
1 parent 83c8847 commit ae6dfd1
Show file tree
Hide file tree
Showing 4 changed files with 226 additions and 37 deletions.
44 changes: 35 additions & 9 deletions docs/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,72 +23,98 @@ guessImageTypeGetImageSize(string $imagePath): string | false;

## isGdAvailable


Check if the GD library is available on the server.

```php
use Esi\Utility\Image;

if (Image::isGdAvailable() {
// ... run some GD related code here...
}
```

## isGmagickAvailable


Check if the GraphicsMagick library is available on the server.

```php
use Esi\Utility\Image;

if (Image::isGmagickAvailable() {
// ... run some GD related code here...
}
```

## isImagickAvailable


Check if the ImageMagick library is available on the server.

```php
use Esi\Utility\Image;

if (Image::isImagickAvailable() {
// ... run some GD related code here...
}
```

## isExifAvailable


Check if the Exif extension is available on the server.

```php
use Esi\Utility\Image;

if (Image::isExifAvailable() {
// ... run some GD related code here...
}
```

## guessImageType


Attempts to determine the image type. It tries to determine the image type with, in order of preference: Exif, finfo, and getimagesize.

```php
use Esi\Utility\Image;

echo Image::guessImageType('/some/folder/image.jpg'); // 'image/jpeg'
```

## isJpg


Checks if image has JPG format.

```php
use Esi\Utility\Image;

var_dump(Image::isJpg('/some/folder/image.jpg')); // bool(true)
```

## isGif


Checks if image has GIF format.

```php
use Esi\Utility\Image;

var_dump(Image::isGif('/some/folder/image.gif')); // bool(true)
```

## isPng


Checks if image has PNG format.

```php
use Esi\Utility\Image;

var_dump(Image::isPng('/some/folder/image.png')); // bool(true)
```

## isWebp


Checks if image has WEBP format.

```php
use Esi\Utility\Image;

var_dump(Image::isWebp('/some/folder/image.webp')); // bool(true)
```
1 change: 1 addition & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Make sure you include `vendor/autoload.php` in your application. To make all of
```php
use Esi\Utility\{
Arrays,
Conversion,
Dates,
Environment,
Filesystem,
Expand Down
63 changes: 57 additions & 6 deletions docs/numbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,91 @@

## inside


Determines if a number is inside the min and max.

```php
use Esi\Utility\Numbers;

var_dump(Numbers::inside(25, 24, 26)); // bool (true)
var_dump(Numbers::inside(25, 26, 27)); // bool (false)

var_dump(Numbers::inside(25.0, 24.0, 26.0)); // bool (true)
var_dump(Numbers::inside(25.0, 26.0, 27.0)); // bool (false)
```

## outside


Determines if a number is outside the min and max.

```php
use Esi\Utility\Numbers;

var_dump(Numbers::outside(23, 24, 26)); // bool (true)
var_dump(Numbers::outside(25, 24, 26)); // bool (false)

var_dump(Numbers::outside(23.0, 24.0, 26.0)); // bool (true)
var_dump(Numbers::outside(25.0, 24.0, 26.0)); // bool (false)
```

## random


Generate a cryptographically secure pseudo-random integer.

```php
use Esi\Utility\Numbers;

$int = Numbers::random(100, 250); // >= 100 <= 250
var_dump($int >= 100); // bool (true)
var_dump($int <= 250); // bool (true)
```

## ordinal


Retrieve the ordinal version of a number.
Basically, it will append th, st, nd, or rd based on what the number ends with.

```php
use Esi\Utility\Numbers;

echo Numbers::ordinal(1); // 1st
echo Numbers::ordinal(102); // 102nd
echo Numbers::ordinal(143); // 143rd
echo Numbers::ordinal(1_004); // 1004th
```

## sizeFormat


Format bytes to a human-readable format.

```php

use Esi\Utility\Numbers;

$sizes = [
512 => 0,
2_048 => 1,
25_151_251 => 2,
19_971_597_926 => 2,
2_748_779_069_440 => 1,
2_748_779_069_440 * 1_024 => 1,
2_748_779_069_440 * (1_024 * 1_024) => 1,
];

$readable = [];

foreach ($sizes as $size => $precision) {
$readable[] = Numbers::sizeFormat($size, $precision);
}

print_r($readable);

/*
Array (
0 => '512 B',
1 => '2.0 KiB',
2 => '23.99 MiB',
3 => '18.60 GiB'
4 => '2.5 TiB',
5 => '2.5 PiB',
6 => '2.5 EiB',
)
```
Loading

0 comments on commit ae6dfd1

Please sign in to comment.