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 Product | |
{ | |
protected $id; | |
protected $name; | |
public function __construct($id, $name) | |
{ | |
$this->id = $id; |
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 | |
interface PluginServiceProvider | |
{ | |
public function register(Plugin $plugin): void; | |
} | |
class Plugin | |
{ | |
protected $methods = []; |
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 | |
abstract class Entity | |
{ | |
abstract public function config(): array; | |
public function validate() | |
{ | |
$config = $this->config(); | |
$errors = []; |
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 | |
$i = 1; | |
function plus1(int $i) { | |
return $i + 1; | |
} | |
$f = function () use ($i) { | |
echo plus1($i); |
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 ComplexPeriod extends DatePeriod | |
{ | |
public function __construct($start, $end) | |
{ | |
parent::__construct( | |
new \DateTime(date("Y-m-d", strtotime($start))), | |
new \DateInterval('P1D'), | |
new \DateTime(date("Y-m-d", strtotime($end))) |
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 | |
function parseCsv($csv, $delimiter = ',') | |
{ | |
// parse rows | |
$rows = explode("\n", trim($csv)); | |
// parse header and header columns | |
$header = explode($delimiter, trim(reset($rows))); | |
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 | |
function slugify($sVal, $sDelimiter = '-') | |
{ | |
$sVal = preg_replace("/[^a-zA-Z0-9_-]/", $sDelimiter, $sVal); | |
$sVal = preg_replace("/$sDelimiter{2,}/", $sDelimiter, $sVal); | |
return trim($sVal, $sDelimiter); | |
} |
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 | |
// start date current month | |
$day = 01; | |
$month = date('m'); | |
$year = date('Y'); | |
$today = date('d-m-Y'); | |
$period = new DatePeriod( |
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 Match | |
{ | |
public function __construct($pattern, $data, $match) | |
{ | |
$this->pattern = $pattern; | |
$this->data = $data; | |
$this->match = $match; | |
} |
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 | |
$timezones = []; | |
foreach(DateTimeZone::listIdentifiers() as $timezone) | |
{ | |
$timezoneWithContinent = explode('/', $timezone); | |
if (count($timezoneWithContinent) == 1) { | |
// skip UTC | |
continue; |