Skip to content

Instantly share code, notes, and snippets.

View manuakasam's full-sized avatar

Manuel St. manuakasam

  • Germany, NRW, Duisburg
View GitHub Profile
@manuakasam
manuakasam / Module.php
Created October 5, 2015 12:25
Config stuff
<?php
namespace Foo;
class Module
{
/* This config willk be cached */
public function getConfig() { return []; }
/**
* This config will NOT be cached
@manuakasam
manuakasam / CoreData.php
Last active September 28, 2015 09:24
Notice: Undefined property: DrWolff\EventManagement\Entity\MetaData::$metaData in /cbx/htdocs/dw-event-management-website/vendor/dr-wolff/event-management/src/Entity/WithProviderForImmutables.php on line 55 Fatal error: Call to a member function with() on a non-object in /cbx/htdocs/dw-event-management-website/vendor/dr-wolff/event-management/sr…
<?php
namespace DrWolff\EventManagement\Entity\Seminar;
use DrWolff\EventManagement\Entity\MetaData;
use DrWolff\EventManagement\Entity\MetaDataProvider;
use DrWolff\EventManagement\Entity\WithProviderForImmutables;
final class CoreData
{
@manuakasam
manuakasam / FooHydratort.php
Last active September 28, 2015 08:37
Dafaq
<?php
/**
* @author Manuel Stosic <manuel.stosic@krankikom.de>
*/
namespace DrWolff\EventManagement\Hydrator\Seminar;
use DrWolff\EventManagement\Entity\Seminar\CoreData;
use Zend\Stdlib\Hydrator\HydratorInterface;
<?php
class Foo
{
public function doStuff($i) {
if ($i < 10) {
return "{$i}";
} else {
return $this->protectedStuff($i);
}
}
<?php
namespace Foo;
use PHPUnit_Framework_TestCase;
use Zend\InputFilter\InputFilter;
class FooTest extends PHPUnit_Framework_TestCase
{
public function testWtf()
{
<?php
$filter = new CollectionInputFilter();
$filter->setInputFilter(new RegistrationFilter());
$filter->setData($data);
$filter->isValid();
$filter->getMessages();
<?php
class RowValidator
{
private $data;
private $filter;
private $errors;
public function __construct($inputFilterInterface, $data)
{
$this->filter = $inputFilterInterface;
@manuakasam
manuakasam / bar.php
Created March 31, 2015 12:54
Is it really this bad to use goto in a switch statement? Imo this is much more user-friendly as far as readability AND code-maintenance is concerned.
<?php
$complexArray = [
//... lots of stuff
'condition' => 'unknown'
];
switch ($someThingElse) {
case 'foo':
default:
$complexArray['condition'] = 'foo';
### Install OpenJDK
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Download and Install ElasticSearch
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.4.deb
sudo dpkg -i elasticsearch-1.4.4.deb
<?php
class FooController {
public function __construct(FooService $foo) {
$this->foo = $foo;
}
public function indexAction() {
return new ViewModel([
'data' => $foo->listStuff();
]);