PHP code example of safronik / helpers

1. Go to this page and download the library: Download safronik/helpers 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/ */

    

safronik / helpers example snippets


HelperArray::insert( $array_passed by_link, $insert_position, $insert_value); // Modifies the array $array. Paste $insert on $position

$array_from_json = HelperData::unpackIfJSON( $json_data );
$token           = HelperData::createToken(); // Generates UUID

get([ip_types: array|string[] = [...]], [v4_only: bool = true]): array|mixed|null
getDecimal([ip: null|string = null]): int
isPrivateNetwork(ip: string, [ip_type: string = 'v4']): bool
isIPInMask(ip: string, cidr: array|string, [ip_type: string = 'v4'], [xtet_count: int = 0]): bool
convertLongMaskToNumber(long_mask: int): int
validate(ip: string): bool|string
cidrValidate(cidr: string): bool
normalizeIPv6(ip: string): string
reduceIPv6(ip: string): string
resolveIP(ip): string

// Scan directory and its subdirectories. Could filter the set by different parameters
HelperReflection::getClassesFromDirectory(
    directory: string,                      // Directory path
    namespace: string,                      // Directory namespace
    [exclusions: string[] = [...]],         // Exclusions. Full strict comparison 
    [filter: string = ''],                  // Positive filter (only string contains will be present in the result set)  
    [recursive: bool = false],              // Scan subdirectories 
    [skip_infrastructure: bool = true],     // Skip classes starts with '_' (underscore symbol)
    [filter_callback: callable|null = null] // Any callback you want to filter the result set. Other methods of self could be passed as a callback filter 
): array

// Filter everything except final classes from the given set 
HelperReflection::filterFinalClasses(classes): array

// Filter everything except interfaces from the given set 
HelperReflection::getInterfacesFromDirectory(classes): array

// Check if the given class use specific trait
HelperReflection::isClassUseTrait(classname: string, trait: string): bool

// Gets class traits
HelperReflection::getClassTraits(classname: string): array

// Filter everything except classes which are implement specific interface from the given set 
HelperReflection::filterClassesByInterface(classes: array, interface: string): array

// // Check if the given class implements specific interface
HelperReflection::isClassHasInterface(class: object|string, interface: string): bool

getCSVMap(&csv: string): array
parseCSV(&scv_string: string): array
parseNSV(nsv_string: string): string[]
convertCSVToArray(&csv: string, [map: array = [...]]): array
convertCSVLineToArray(&csv: string, [map: array = [...]], [stripslashes: bool = false]): array
cleanUpCSV(&buffer: array): array
popCSVLine(&csv: string): string

isExist(path): bool
isEmpty(path): bool
create(path): void

resolveHost(host: string): string

http__request(url: string, [data: array = [...]], [presets: array|null|string = null], [opts: array = [...]]): array|string[]|bool|int|string
http__request__get_content(url: string): array|string[]|bool|int|mixed|string
http__request__get_response_code(url: string): array|string[]|bool|int|mixed|string
http__get_data_from_remote_gz(url: string): array|false|mixed|string
get_data_from_local_gz(path: string): array|string[]|mixed|string
http__download_remote_file(url, tmp_folder): array|string[]|bool|int|string
http__download_remote_file__multi(urls: array, [write_to: string = '']): array|string[]

hasError(string_page): bool

removeNonUTF8(data: array|object|string): array|object|string
toUTF8(data: array|object|string, [data_codepage: null|string = null]): array|object|string
fromUTF8(obj: array|object|string, [data_codepage: null|string = null]): mixed

isWindows(): bool
isExtensionLoaded(extension_name): bool

getIntervalStart(interval: int): int

isCorrectSemanticVersion(version: string): bool
standardizeVersion(version): string
compare(version1: string, version2: string): int