Instantly share code, notes, and snippets.
Dennis Jungbauer d4rkne55
Web-Developer |
Also interested in PC hardware, Hi-Fi audio, traveling and photography.
- Germany
| <?php |
| class Time |
| { |
| public $h; |
| public $i; |
| public $s; |
| public $f; |
| private static $unitData = array( |
| <?php |
| class JsonDumper |
| { |
| /** @var string */ |
| private $json; |
| /** @var int spaces to use for one indentation level */ |
| private $indentation; |
| <?php |
| class AsciiTable |
| { |
| private $rows; |
| private $columns; |
| private $headers = array(); |
| private $data = array(); |
| private $separators; |
| private $headerPadMethod; |
d4rkne55
/ NumberSpell.class.php
Last active
Class for getting the spelled out string of a number (was a coding challenge once)
| <?php |
| class NumberSpell |
| { |
| public $number; |
| public $spelled; |
| private $rules = array( |
| 0 => array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'), |
| 1 => array(null, 'twen', 'thir', 'for', 'fif', null, null, null, null) |
| <?php |
| /** |
| * This class brings support for milliseconds, explicit recalculation of carry-over points |
| * and human-friendly formatting |
| */ |
| class DateIntervalEnhanced extends DateInterval |
| { |
| public $ms = 0; |
| private $unitData = array( |
| <?php |
| class StringTransform |
| { |
| /** |
| * This Method Converts a String to Title Case |
| * Not context-aware and just for english. |
| * |
| * @param string $str |
| * @param bool $apStyle use AP-Style title case if true |
d4rkne55
/ Media.class.php
Last active
Class with some calculations and informations for media files
| <?php |
| class Media |
| { |
| public $calcBase = 1024; |
| public $fileSize = 0; |
| public $sizePrefixes = array( |
| 1000 => array( |
| '', |
| 'K', |
d4rkne55
/ parseColorString.php
Created
This function is for parsing legacy color values. It is based on the WHATWG specs.
| <?php |
| function parseColorString($str, $format = 'hex') { |
| $str = strtolower(trim($str)); |
| // prevent errors for an empty string and ignore 'transparent' |
| if ($str == '' || $str == 'transparent') { |
| return false; |
| } |
| // replace nonvalid hex characters with 0 |
