Skip to content

Instantly share code, notes, and snippets.

View ismail1432's full-sized avatar
🏠
Looking for remote job

Smaine Milianni ismail1432

🏠
Looking for remote job
View GitHub Profile
<?php
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class BazController
{
/**
*@Route("/show")
*/
public function show(EventDispatcherInterface $eventDispatcher)
{
<?php
// Simple hydrator
final class Hydrator
{
public function hydrate($object, array $data = [])
{
foreach ($data as $property => $value) {
$method = 'set'.ucfirst($property);
if (\method_exists($object, $method)) {
$object->{$method}($value);
<?php
namespace App\Entity;
class User
{
public $login;
public $id;
public static function create(array $data)
<?php
namespace App\Service;
use App\Entity\User;
use Symfony\Contracts\HttpClient\HttpClientInterface;
class GithubUserRepository
{
private $githubClient;
Feature:
In order to fetch a User from Github
As a developer
I want to have a repository that fetch a User from a username
Scenario: Fetch a User from Github by a username
Given The response have the following body:
| id | 42 |
| login | ismail1432 |
When I fetch a user with username ismail1432
<?php
namespace App\Tests\Behat;
final class GithubContext implements Context
{
/** @var GithubUserRepository $githubRepo */
private $githubRepo;
/** @var App\Entity\User $user */
private $user;
<?php
class PostContentController
{
/**
* @Route("/contents", name="post_content", methods="POST")
*/
public function __invoke(NotifierInterface $notifier, Request $request)
{
if(null !== $message = (\json_decode($request->getContent(), true)['message'] ?? null)) {
<?php
// Kernel.php
public function getLogDir(): string
{
if (getenv('LAMBDA_TASK_ROOT') !== false) {
return '/tmp/log/';
}
return parent::getLogDir();
}
service: notifier-linkedin-api
provider:
name: aws
region: eu-west-3
runtime: provided
environment: # env vars
APP_ENV: prod
LINKEDIN_DSN: YOUR_DSN
<?php
class PostContentControllerTest extends WebTestCase
/**
* @dataProvider methodProvider
*/
public function testANoPostRequestShouldReturnA405(string $method)
{
$client = static::createClient();
$client->request($method, '/contents');