This file contains hidden or 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
<?php | |
class BaseTestCase extends \PHPUnit_Framework_TestCase | |
{ | |
/** | |
* Creates an arbitrary object with specified property values. | |
* | |
* @param string $className | |
* @param array $propertyValues | |
* |
This file contains hidden or 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
<?php | |
class RandomStringGenerator | |
{ | |
const DEFAULT_ALPHABET = 'abcdefghijklmnopqrstuvwxyz0123456789'; | |
/** | |
* Generates a random string of requested length and from given alphabet. | |
* | |
* @param int $stringLength | |
* @param string $alphabet |
This file contains hidden or 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
<?php | |
// @see https://www.elastic.co/guide/en/elasticsearch/reference/5.x/date-math-index-names.html | |
// @TODO <elastic\\{ON\\}-{now/M}> | |
function escapePathWithDateMath($path) | |
{ | |
$symbols = ['<', '>', '/', '{', '}', '|', '+', ':', ',']; | |
$escaped = ['%3C', '%3E', '%2F', '%7B', '%7D', '%7C', '%2B', '%3A', '%2C']; | |
// Check if the string is already escaped |
This file contains hidden or 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
<?php | |
// Trims whitespaces after any tags. Assumes that a tag ends with '/>', '\w>', '">'. | |
$html = preg_replace('#(["|\/|\w]>)(\s+)#', '$1', $html); | |
// Trims whitespaces before any tags. Assumes that tags start with '<\w+' | |
$html = preg_replace('#(\s+)(<\/?\w+)#', '$2', $html); | |
// Trims spaces between tags (both opening and closing). | |
// Assumes that a tag ends with '/>', '\w>', '">' and starts with '<\w+' |
This file contains hidden or 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
function roundFloat(number, decimals) { | |
return (Math.round(number * (Math.pow(10, decimals))) / Math.pow(10, decimals)).toFixed(decimals) | |
} |
This file contains hidden or 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
<?php | |
/** | |
* Expresses a given number in a a-z letter base, e.g.: | |
* 0 -> a, 27 -> ba, 932 -> bjw, ... | |
* | |
* @param int $number | |
* | |
* @return string | |
*/ |
This file contains hidden or 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
<?php | |
/** | |
* Counts the number of lines in a container where character count per line is known or approximate. | |
* It assumes that words can be broken. | |
* | |
* @param string $text | |
* @param int $perLine | |
* | |
* @return int |
This file contains hidden or 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
// jQuery warriors, assemble! | |
$.fn.cachedFind = function (selector) { | |
var cache = this.data('cached-find') || {}; | |
if (undefined === cache[selector]) { | |
cache[selector] = this.find(selector); | |
this.data('cached-find', cache); | |
} | |
return cache[selector]; | |
}; |
This file contains hidden or 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
export function lpad(pad, string) { | |
var trueString = '' + string; | |
return pad.substring(0, pad.length - trueString.length) + trueString; | |
} |
This file contains hidden or 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
<?php | |
/** | |
* Returns customer notifications | |
* | |
* @param int|null $limit | |
* @param int|null $afterId | |
* @param int|null $beforeId | |
* | |
* [0]*************************************[totalRows] |