Skip to content

Instantly share code, notes, and snippets.

View nexik's full-sized avatar

Tomasz Ślązok nexik

View GitHub Profile
<?php
define('HOUR', 3600);
define('MINUTE', 60);
interface Time
{
  public const HOUR = 3600;
public const MINUTE = 60;
}
<?php
class Hour
{
/**
* Returns number of seconds in one hour
*/
public function toInt(): int
{
return 3600;
}
@nexik
nexik / tags.php
Created February 22, 2016 12:31
Extract picture tags
<?php
function getTags($file)
{
getimagesize($file, $info);
if (isset($info["APP13"])) {
$meta = iptcparse($info["APP13"]);
return isset($meta['2#025']) ? $meta['2#025'] : '';
@nexik
nexik / AppBundle.php
Created October 17, 2015 20:46
doctrine custom mapping
<?php
namespace AppBundle;
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AppBundle extends Bundle
{
public Integer max(Integer a, Integer b) {
return new If(
new GreaterThan(a, b),
a, b
);
}
@nexik
nexik / slider.php
Last active August 29, 2015 14:22
Slider
<?php
function alternate()
{
static $i;
if (func_num_args() === 0) {
$i = 0;
return '';
}
@nexik
nexik / User.EmailAddress.orm.yml
Created December 20, 2014 22:16
User EmailAddress Value Object Mappings Doctrine2
AppBundle\Entity\User\EmailAddress:
type: embeddable
fields:
address:
column: email
type: string
length: '250'
@nexik
nexik / EmailAddress.php
Created December 20, 2014 22:11
User and EmailAddress as ValueObject
<?php
namespace AppBundle\Entity\User
class EmailAddress
{
private $address;
public function __construct($address)
{
@nexik
nexik / gist:0423f66405a596f99688
Last active August 29, 2015 14:10
jQuery WTF
$(function() {
var centerAbsolute = function () {
$('.absolute-center').css({
position:'absolute',
left: ($(window).width() - $('.absolute-center').outerWidth())/2,
top: ($(window).height() - $('.absolute-center').outerHeight())/2
});
}
centerAbsolute();
@nexik
nexik / DevHelper.php
Created April 19, 2014 23:31
SpecBDD in Codeception
<?php
namespace Codeception\Module;
use Codeception\Module;
use Codeception\PHPUnit\AssertWrapper;
use Closure;
class DevHelper extends Module
{
private $testSubject;