This file contains 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 | |
final class EmailValueObject | |
{ | |
private $mailbox; | |
private $host; | |
public function __construct($email) | |
{ | |
if (false === strpos($email, '@')) { |
This file contains 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
#!/bin/bash | |
exec < /dev/tty | |
phpunit | |
rc=$? | |
if [[ $rc != 0 ]] ; then | |
echo -n "It looks like some of your tests failed. " | |
exit $rc; | |
fi |
This file contains 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 | |
$log = __DIR__ . '/api.log'; | |
if ('POST' == $_SERVER['REQUEST_METHOD']) { | |
$payload = json_decode(file_get_contents('php://input'), true) ?: $_POST; | |
file_put_contents( | |
$log, | |
sprintf( | |
"[%s] (%s - %s) %s\n", | |
(new \DateTime())->format('Y-m-d H:i:s'), |
This file contains 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
$poundToEuro = (float) simplexml_load_file('https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml')->xpath("//*[@currency='GBP']")[0]['rate']; |
This file contains 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
{ | |
"name": "wowo/log-demo", | |
"type": "project", | |
"require": { | |
"monolog/monolog": "^2.0" | |
}, | |
"authors": [ | |
{ | |
"name": "Wojciech Sznapka", | |
"email": "[email protected]" |
This file contains 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
<container xmlns="http://symfony.com/schema/dic/services" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="[..]"> | |
<parameters> | |
<parameter key="example.foo.repository.class"> | |
Example\FooBundle\Repository\FooRepository</parameter> | |
<parameter key="example.foo.service.class"> | |
Example\FooBundle\Service\FooService</parameter> | |
</parameters> |
This file contains 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 | |
namespace Example\FooBundle\Repository; | |
use Doctrine\ORM\EntityRepository; | |
class FooRepository extends EntityRepository | |
implements FooRepositoryInterface | |
{ | |
public function fetchLatest() |
This file contains 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 | |
namespace Example\FooBundle\Service; | |
use Doctrine\ORM\EntityRepository; | |
use Symfony\Component\HttpKernel\Log\LoggerInterface; | |
class FooService | |
{ | |
protected $fooRepository; |
This file contains 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 | |
namespace Example\FooBundle\Repository; | |
use Doctrine\Common\Persistence\ObjectRepository; | |
interface FooRepositoryInterface extends ObjectRepository | |
{ | |
public function fetchLatest(); | |
} |
This file contains 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
<container xmlns="http://symfony.com/schema/dic/services" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="[..]"> | |
<parameters> | |
<parameter key="example.foo.repository.class"> | |
Example\FooBundle\Repository\FooRepository</parameter> | |
<parameter key="example.foo.service.class"> | |
Example\FooBundle\Service\FooService</parameter> | |
</parameters> |