imonroe / ana
Ana 是我个人的 PHP 7 兼容辅助函数库
1.0.5
2018-06-17 03:21 UTC
Requires
- php: ~5.6|~7.0
Requires (Dev)
- phpunit/phpunit: ~4.0||~5.0||~6.0
- squizlabs/php_codesniffer: ^2.3
README
安装
通过 Composer
$ composer require imonroe/ana
使用
use imonroe\ana\Ana; $formatted_date = Ana::standard_date_format(strtotime('yesterday')); if (Ana::even_or_odd(2) == 'even'){ // do something } if (Ana::is_valid_link('https://www.google.com')){ // link is valid and curl-able } // grab a file from the web and save it to a text file. Ana::create_file('sample.txt', Ana::quick_curl('https://www.sample.com/index.html'), true);
可用方法
所有方法都是静态的。
- standard_date_format($timestamp = '')
- sql_datetime($timestamp = '')
- google_datetime($timestamp = '')
- is_today($date_string)
- sooner_than($date_string)
- later_than($date_string)
- print_relative_date($date)
- fatal_handler()
- dd($var)
- array_unique_multi($arr)
- array_sort_by_column(&$arr, $col, $dir = SORT_ASC)
- object_to_array($object)
- build_tree($flat, $pidKey, $idKey = null)
- csv_to_array($filename='', $delimiter=',')
- plural($quantity)
- word_limit($haystack, $ubound)
- convert_to_utf($input)
- plain_text($input)
- trim_string_to_length($str, $len)
- use_a_or_an($text)
- even_or_odd($number)
- random_number($lowbound = 1, $highbound = 100)
- random_hex($bytes = 8)
- generateStrongPassword($length = 9, $add_dashes = false, $available_sets = 'luds')
- create_nonce()
- current_page_url()
- get_url_segment($number)
- is_valid_link($link)
- quick_curl($link)
- get_ip()
- submit_post_request($url, $data)
- loading_spinner()
- code_safe_name($string)
- cast($destination, $sourceObject)
- ask_user($prompt)
- say($msg)
- error_out($msg)
- create_directory($directory_path, $perms = 0777)
- remove_directory($path)
- create_file($file_path_and_name, $file_content, $overwrite = false)
- append_file($file_path_and_name, $file_content, $overwrite = false)
- get_url_and_save($fully_qualified_url, $filename)
- read_file_to_string($filename)
- get_directory_list($directory_path)
- execute($cmd)
- get_arguments()
- replace_line_in_file(String $filename='', String $line_to_change='', String $change_to='')
- replace_and_save($oldFile, $search, $replace, $newFile = null)
- us_states()
变更日志
请参阅 CHANGELOG 了解最近更改的详细信息。
测试
$ composer test
贡献
请参阅 CONTRIBUTING 和 CONDUCT 了解详细信息。
安全
如果您发现任何安全相关的问题,请通过电子邮件 ian@ianmonroe.com 而不是使用问题跟踪器。
致谢
许可
MIT 许可证 (MIT)。请参阅 许可文件 了解更多信息。