-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed Code of Conduct. * Refactoring tests to support more. * #22 Added support for: date_format, LPAD, mod, minute, format, CONVERT_TZ, TIMEDIFF, UNIX_TIMESTAMP, weekday, inet_ntoa, and date_add with select intervals * #22 Added DIV Operator * #22 Added a Test for an edge case from @DrLongGhost * #16 Cleaned up composer.json
- Loading branch information
1 parent
73c8ba3
commit d720000
Showing
21 changed files
with
846 additions
and
105 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Mhorninger\MySQLite; | ||
|
||
class MethodRewriteConstants | ||
{ | ||
const METHOD_REPLACEMENTS = [ | ||
'/(DATE_ADD)(?=.*?, INTERVAL.*?\\))/' => 'datetime', | ||
'/INTERVAL (?=.*?\\))/' => '\'+', | ||
'/INTERVAL (?=.*?\\))/' => '\'+', | ||
'/SECOND(?=\\))/' => 'seconds\'', | ||
'/MINUTE(?=\\))/' => 'minutes\'', | ||
'/HOUR(?=\\))/' => 'hours\'', | ||
'/DAY(?=\\))/' => 'days\'', | ||
'/WEEK(?=\\))/' => 'weeks\'', | ||
'/MONTH(?=\\))/' => 'months\'', | ||
'/YEAR(?=\\))/' => 'years\'', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Mhorninger\MySQLite\MySQL; | ||
|
||
trait Miscellaneous | ||
{ | ||
//phpcs:disable | ||
public static function mysql_inet_ntoa($numeric) | ||
{ | ||
//phpcs:enable | ||
if ($numeric && is_numeric($numeric)) { | ||
return long2ip(sprintf('%d', $numeric)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Mhorninger\MySQLite\MySQL; | ||
|
||
trait NumericExtended | ||
{ | ||
// phpcs:disable | ||
public static function mysql_mod($number, $divisor) | ||
{ | ||
//phpcs:enable | ||
if ($number && $divisor) { | ||
return fmod($number, $divisor); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Mhorninger\MySQLite\MySQL; | ||
|
||
use NumberFormatter; | ||
|
||
trait StringExtended | ||
{ | ||
/** | ||
* Format a number according to the nubmer of decimals provided and culture. | ||
* @param mixed... number, decimals, culture. | ||
*/ | ||
// phpcs:disable | ||
public static function mysql_format() | ||
{ | ||
//phpcs:enable | ||
$args = func_get_args(); | ||
$length = count($args); | ||
if ($args && 0 < $length && ($number = $args[0]) != null) { | ||
$decimals = 1 < $length ? $args[1] : 0; | ||
$culture = 2 < $length ? $args[2] : 'en_US'; | ||
$pattern = '#,##0'; | ||
if ($decimals > 0) { | ||
$pattern = $pattern.'.'; | ||
$base = strlen($pattern); | ||
$decimals = $base + $decimals; | ||
$pattern = str_pad($pattern, $decimals, '0', STR_PAD_RIGHT); | ||
} | ||
$formatter = new NumberFormatter($culture, NumberFormatter::PATTERN_DECIMAL, $pattern); | ||
|
||
return $formatter->format($number); | ||
} | ||
} | ||
|
||
// phpcs:disable | ||
public static function mysql_lpad($string, $length, $pad) | ||
{ | ||
//phpcs:enable | ||
if ($string && $length && $pad) { | ||
if (strlen($string) < $length) { | ||
return str_pad($string, $length, $pad, STR_PAD_LEFT); | ||
} | ||
|
||
return substr($string, 0, $length); | ||
} | ||
} | ||
} |
Oops, something went wrong.