Skip to content

Instantly share code, notes, and snippets.

@mikemix
mikemix / classmap-generator.bat
Last active August 29, 2015 13:56
ZF2 application classmap generator
REM Created by Michal Zukowski (github.com/mikemix)
REM
REM Put this file inside ZF2_ROOT/bin directory for your convenience.
REM You are welcome.
REM
REM To make use of generated class map, configure your Module.php file as follows
REM
REM /**
REM * @return array
REM */
@mikemix
mikemix / TranslatorDelegator.php
Created June 5, 2014 11:12
Translator delegator
<?php
namespace Common\Form\Delegator;
use Zend\ServiceManager\DelegatorFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Validator\AbstractValidator;
class TranslatorDelegator
{
public function createDelegatorWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback)
<?php
class User {
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
@mikemix
mikemix / MyDateValidator.php
Created October 28, 2014 09:34
MyDateValidator
<?php
namespace Module\Validator;
use Zend\Validator\Date;
class MyDateValidator extends Date
{
public function isValid($value)
{
$this->setValue($value);
@mikemix
mikemix / json serializable.php
Created September 1, 2015 13:56
json serializable
<?php
class Person implements \JsonSerializable
{
public function __construct($name, $surname)
{
$this->name = $name;
$this->surname = $surname;
}
@mikemix
mikemix / spec.php
Last active September 18, 2015 08:08
<?php
interface JobInterface
{
/**
* Czy wartość spełnia kryteria?
*
* @param mixed $value
* @return bool
*/
@mikemix
mikemix / Salt.php
Last active December 10, 2015 23:58
Create random string (salt)
<?php
/**
* Create random string.
*
* @param int $length
* @return string
*/
function getRandomSalt($length=8)
{
@mikemix
mikemix / ImaginaryCalendarFinderInterface.php
Created January 9, 2014 22:00
Job interview task solved: day of week calculation
<?php
interface ImaginaryCalendarFinderInterface
{
/**
* @param int $year
* @param int $month
* @param int $day
* @return int
*/
@mikemix
mikemix / function.php
Created January 10, 2014 07:25
Get tag contents from html
<?php
/**
* @param string $tagName
* @param string $content
*/
function getTagContents($tagName, $content)
{
preg_match_all(sprintf('#<%1$s[^>]+>(.*?)</%1$s>#ism', $tagName), $content, $match);
return isset($match[1]) ? $match[1] : array();
@mikemix
mikemix / SemanticMessengerHelper.php
Last active January 4, 2016 05:49
Renders flashMessenger's messages using Semantic UI markup
<?php
namespace Application\Helper;
use Zend\View\Helper\AbstractHelper;
use Zend\View\Helper\FlashMessenger;
/**
* SemanticMessengerHelper class
*
* Register as plugin helper in application config: