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 | |
use League\Period\Period; | |
$period = new Period('2021-01-01', '2021-04-01'); | |
echo $period; //displays 2021-01-01T00:00:00.000000Z/2021-04-01T00:00:00.000000Z |
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 | |
declare(strict_types=1); | |
namespace Example; | |
final class Geolocation | |
{ | |
private float $latitude; | |
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 | |
use League\Uri\UriTemplate; | |
//$template is a string which complies to RFC6570 | |
$template = 'https://example.com/hotels/{hotel}/bookings/{booking}'; | |
$uriTemplate = new UriTemplate($template); | |
//$variables are the parameters that will be replaced in the template | |
$variables = ['booking' => '42', 'hotel' => 'Rest & Relax']; |
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 | |
namespace Sunday\Dev | |
use Foobar\Great; | |
final class Awesome | |
{ | |
public const AWESOME_NUMBER = 99; |
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 | |
use Doctrine\Common\Collections\Criteria; | |
use League\Csv\Reader; | |
use function Bakame\Csv\Extension\criteria_convert; | |
$criteria = Criteria::create() | |
->andWhere(Criteria::expr()->contains('email', '@gmail.com')) | |
->setFirstResult(0) | |
->setMaxResults(10); |
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 | |
/** | |
* Tell whether the propety or the inner property exists | |
* we do not use isset as isset($obj->foo->bar->baz) would return false | |
* if $obj->foo->bar->baz = null | |
* | |
* Usage: | |
* | |
* if (property_exists($obj, 'foo->bar->baz')) { |
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 | |
use League\Csv\Reader; | |
$formatter = function (array $row) { | |
$row['create_at'] = new DatetimeImmutable($row['create_at']); | |
return $row; | |
}; |
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 | |
$uri = 'http://www.ics.uci.edu/pub/ietf/uri/#Related'; | |
$regexp = ',^ | |
((?<scheme>[^:/?\#]+):)? # URI scheme component | |
(?<authority>//([^/?\#]*))? # URI authority part | |
(?<path>[^?\#]*) # URI path component | |
(?<query>\?([^\#]*))? # URI query component | |
(?<fragment>\#(.*))? # URI fragment component | |
,x'; |
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 | |
namespace Example; | |
use League\Csv\AbstractCsv; | |
use php_user_filter; | |
class RemoveSequence extends php_user_filter | |
{ | |
const FILTER_NAME = 'removesequence.'; |
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 | |
$pdo = new \PDO( | |
$config['db']['dsn'], | |
$config['db']['username'], | |
$config['db']['password'] | |
); | |
$sql = 'SELECT * FROM `gen_contact` ORDER BY `contact_modified` DESC'; | |
$stmt = $pdo->prepare($sql); |