Skip to content

Instantly share code, notes, and snippets.

@GDmac
Created April 1, 2019 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GDmac/f8e6d2fb96a3dfb80102cad831bcb760 to your computer and use it in GitHub Desktop.
Save GDmac/f8e6d2fb96a3dfb80102cad831bcb760 to your computer and use it in GitHub Desktop.
composing objects and make methods and objects testable
<?php
require_once __DIR__ . '/../vendor/autoload.php';
$uploadHandler = new \Acme\FileUpload\UploadHandler();
$uploadHandler
->setFormFieldName('upload')
->setTargetDirectory(__DIR__ . '/../uploads')
->addValidator(new JpegFileTypeValidator())
->addValidator(new maxFileSizeValidator(4096))
->addValidator(new fileExistsValidator()); // don't overwrite existing uploads
// ...
$uploadHandler->handle($_FILES);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment