Skip to content

Instantly share code, notes, and snippets.

View flyingluscas's full-sized avatar
🏠
Working from home

fly flyingluscas

🏠
Working from home
View GitHub Profile
@flyingluscas
flyingluscas / PHPUnitMockTrait.md
Last active March 14, 2017 01:55
PHPUnit: Mocking Trait
use PHPUnit\Framework\TestCase;

trait Greeting
{
    public function hello($name)
    {
        return 'Hello '.$name;
    }
}
@flyingluscas
flyingluscas / PHPUnitMockInterface.md
Created March 14, 2017 01:58
PHPUnit: Mocking Interface
use PHPUnit\Framework\TestCase;

interface Greeting
{
    public function hello($name);
}

class GreetingTest extends TestCase
{
@flyingluscas
flyingluscas / PHPUnitMockAbstractClass.md
Created March 14, 2017 02:02
PHPUnit: Mock abstract class
use PHPUnit\Framework\TestCase;

abstract class Greeting
{
    public function hello($name)
    {
        return 'Hello '.$name;
    }
}
@flyingluscas
flyingluscas / Handler.php
Created March 19, 2017 05:13
Handling exceptions with JSON responses.
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
@flyingluscas
flyingluscas / DragonBallSuper.md
Last active April 1, 2017 06:43
Dragon Ball Super

Dragon Ball Super - Episódio 1

Qualidade HD MQ LQ

@flyingluscas
flyingluscas / docker-compose.yml
Last active April 15, 2017 03:13
Example Docker Compose for Wordpress
version: '2'
services:
wordpress:
image: wordpress:4.7.3-php5.6-apache
container_name: sandbox-wordpress
volumes:
- ./:/var/www/html
ports:
- 8080:80
@flyingluscas
flyingluscas / ArrayReplacementForSwitch.md
Last active April 17, 2017 17:31
Array Replacement for Switch
$subject = 'flying';

switch ($subject) {
    case 'flying':
        $result = 'potato';
        break;

    case 'bacon':
 $result = 'is life';
@flyingluscas
flyingluscas / ReturnReplacementForElse.md
Last active April 17, 2017 17:38
Return Replacement for else

Case One

Wrong

$name = 'Lucas';
$greeting = null;

if (is_null($name)) {
    $greeting = 'No name was provided';
} else {
Route::get('/api/users/{id}', function ($id) {
    return App\User::find($id);
});
{
    "id": 1,
    "name": "Anakin Skywalker",
    "email": "anakin@death.star",
    "created_at": "2017-02-14 01:53:04",
    "updated_at": "2017-02-14 01:53:04"
}