Skip to content

Instantly share code, notes, and snippets.

View yourwebmaker's full-sized avatar
🍊
Back to Reality!

Daniel Lima yourwebmaker

🍊
Back to Reality!
  • Netherlands
View GitHub Profile
@yourwebmaker
yourwebmaker / Entidades.php
Last active January 27, 2017 11:31
Exemplo mostrando desacoplamento de camadas e de framework
<?php
namespace Domain\Entidades;
/**
* Representa uma música no sistema.
* Não importa de onde ela venha: Banco, Cache, WS, FileSystem
*/
class Musica
{
@yourwebmaker
yourwebmaker / PageRepository.php
Last active June 10, 2016 05:03
Just sharing some pieces of code with others. Every file has your own comments described on the top of each one.
<?php
namespace GivenTree\Certification;
/**
* A simple example orepository pattern (http://martinfowler.com/eaaCatalog/repository.html)
* In this example I've used in-memory strategy to retrieve records
* Project: http://test.giventree.org/
* Framework: Laravel
*/
@yourwebmaker
yourwebmaker / DefaultRepository.php
Last active January 15, 2016 00:31
How to mock a Doctrine Custom Repository using Profecy
<?php
declare(strict_types = 1);
namespace App;
use Doctrine\ORM\EntityRepository;
use App\Exception\EntityNotFoundException;
class DefaultRepository extends EntityRepository
{
@yourwebmaker
yourwebmaker / structure-1.md
Last active January 15, 2016 15:10
How to better organize files in non-framework PHP projects. Como organizar melhor arquivos em projetos PHP que não usam frameworks
/public/
    /js/
        /jquery.js
        /app.js
    /css/
        app.css
        some-optional-css-framework.css
    /index.php
 /config.php
@yourwebmaker
yourwebmaker / sample.php
Created January 23, 2016 03:57
Showing how to use Value Objects to get better code maintenance and better design.
<?php
declare(strict_types = 1);
namespace App
{
class Status
{
const ACTIVE = 1;
const INACTIVE = 2;
const SOLD = 3;
@yourwebmaker
yourwebmaker / example-1.php
Last active January 28, 2016 20:59
How to validate relationships on object creation. ---> code execution: https://3v4l.org/t7JqO#v700
<?php
declare(strict_types = 1);
namespace App
{
class Product
{
private $id;
private $name;
private $volumes;

Keybase proof

I hereby claim:

  • I am yourwebmaker on github.
  • I am yourwebmaker (https://keybase.io/yourwebmaker) on keybase.
  • I have a public key whose fingerprint is F952 8B01 EA67 BCA4 24C1 C25C 634D B623 DDA1 8D85

To claim this, I am signing this object:

<?php
namespace OrderExample
{
interface Order
{
public static function create(OrderId $orderId, DateTimeImmutable $orderDate) : Order;
public function addLine(LineNumber $lineId, ProductId $productId, Quantity $quantity) : void;
}
<?php
namespace App\Application
{
//O objectivo 'e deixar as camadas mais acima, mais limpas o possivel
// e nao saber o que acontece depois... envio de email, disparo de notificacao, sms, etc
//como vc pode ver, o controller, so tem 1 dependencia: CommandBus
class UserController
{
public function __construct(CommandBus $commandBus)