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
<?php
class Book
{
private $rates = [];
public function rate(string $userId, int $rate) : void
{
if (isset($this->rates[$userid])) {
throw new AlreadyRatedThisBook();
}
<?php
class FooEntity
{
public string $entityId;
public DateTime $date;
public function __construct(string $entityId, DateTime $date)
{
$this->entityId = $entityId;
$this->date = $date;
[
{
"region": "Amsterdam",
"liquidity": 80,
"published": 123
},
{
"region": "Utrecht",
"liquidity": 76,
"published": 321
<?php
declare(strict_types=1);
namespace PHPBrasil\ExemploTest;
use PHPUnit\Framework\TestCase;
class ExemploMockStub extends TestCase
{
<?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)
<?php
namespace OrderExample
{
interface Order
{
public static function create(OrderId $orderId, DateTimeImmutable $orderDate) : Order;
public function addLine(LineNumber $lineId, ProductId $productId, Quantity $quantity) : void;
}

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:

@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;
@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 / 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