Skip to content

Instantly share code, notes, and snippets.

View KaiCMueller's full-sized avatar

Kai Müller KaiCMueller

View GitHub Profile
@KaiCMueller
KaiCMueller / TablePrefixEventListener.php
Created February 21, 2020 08:56
Symfony: Add an automatic table prefix with Doctrine
<?php
namespace App\EventListener;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
class TablePrefixEventListener
{
/**
@KaiCMueller
KaiCMueller / TablePrefixEventListener.php
Created February 21, 2020 09:06
Symfony: Add an automatic table prefix with Doctrine
<?php
namespace App\EventListener;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
class TablePrefixEventListener
{
/**
@KaiCMueller
KaiCMueller / WorkingDaysCalculator.php
Created April 6, 2020 12:53
Calculation of next working day date
class WorkingDaysCalculator
{
const SUNDAY = 0;
const SATURDAY = 6;
/**
* Get next working day date
*
* @param \DateTime $baseDate - default now
* @param int $additionalWorkingDays - default 0
@KaiCMueller
KaiCMueller / getCalendarYearWeek.php
Last active July 16, 2020 14:42
Get year and week number as 6 digit integer from any DateTime object including fix for in between the years
<?php
/**
* @param \DateTime $dateTime
*
* @return int - e.g. 202001
*/
protected function getCalendarYearWeek(DateTime $dateTime): int
{
$week = $dateTime->format('W');