PHP code example of camelot / common

1. Go to this page and download the library: Download camelot/common library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

camelot / common example snippets


isArrayAccessible($value, string $message = ''): void

isInstanceOfAny($value, string[] $classes, string $message = ''): void

isIterable($value, string $message = ''): void

warn(string $subject, string|float $since = null, string $suggest = ''): void

// Triggers warning: "Doing foo is deprecated."
Deprecated::warn('Doing foo');

// Triggers warning: "Doing foo is deprecated since 3.3 and will be removed in 4.0."
Deprecated::warn('Doing foo', 3.3);

// Triggers warning: "Doing foo is deprecated since 3.3 and will be removed in 4.0. Do bar instead."
Deprecated::warn('Doing foo', 3.3, 'Do bar instead');

method(string|float $since = null, string $suggest = '', string $method = null): void

class Foo
{
    public function world()
    {
        // Triggers warning: "Foo::world() is deprecated since 3.3 and will be removed in 4.0. Use hello() instead."
        Deprecated::method(3.3, 'hello');
    }
}

cls(string $class, string|float $since = null, string $suggest = null): void

// Triggers warning: "Foo\Bar is deprecated."
Deprecated::cls('Foo\Bar');

// Triggers warning: "Foo\Bar is deprecated. Use Bar\Baz instead."
Deprecated::cls('Foo\Bar', null, 'Bar\Baz');

has(string $key): bool

getStr(string $key, string $default = null): ?string

getBool(string $key): bool

getNumeric(string $key, int|float $default = null): int|float|null

getBytes(string $key, int $default = null): ?int

set(string $key, ?scalar $value): void

parse(string $json, int $options = 0, int $depth = 512): string

dump(mixed $data, int $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE, int $depth = 512): string

test(string $json): bool

parse(string $value, array $options = []): mixed

dump(mixed $value): string

replaceFirst(string $subject, string $search, string $replace, bool $caseSensitive = true): string

replaceLast(string $subject, string $search, string $replace, bool $caseSensitive = true): string

removeFirst(string $subject, string $search, bool $caseSensitive = true): string

removeLast(string $subject, string $search, bool $caseSensitive = true): string

splitFirst(string $subject, string $delimiter): string

splitLast(string $subject, string $delimiter): string

endsWith(string $subject, string $search, bool $caseSensitive = true): bool

className(string|object $class): string

humanize(string $text): string

camelCase(string $text, bool $lowercaseFirstChar = false): string

snakeCase(string $text): string