Skip to content

Instantly share code, notes, and snippets.

@murilozilli
murilozilli / dateHelper.php
Last active October 23, 2020 08:53
Get a number of business days after date
<?php
/**
* Created by PhpStorm.
* User: murilo
* Date: 23/10/20
* Time: 5:53 PM
*/
class DateHelper
{
//change at will
@murilozilli
murilozilli / CamelToSnake.php
Last active February 14, 2020 02:35
CamelCase to Snake_case
<?php
function camelToSnake($input)
{
if (preg_match('/[A-Z]/', $input) === 0) {
return $input;
}
$pattern = '/([a-z])([A-Z])/';
$r = strtolower(preg_replace_callback($pattern, function ($a) {
return $a[1] ."_". strtolower($a[2]);
}, $input));
@murilozilli
murilozilli / Model.php
Last active February 14, 2020 03:04
Constant validation by value
<?php
namespace Application\Model;
class Model
{
/**
* @var string
*/
const TYPE_PDF = 'pdf';
@murilozilli
murilozilli / IndexController.php
Last active March 8, 2017 17:23
Zend Framework 2.x(zf2) methods to download excel files using PHPExcel
<?php
namespace App\Controller;
use Zend\Mvc\Controller\AbstractActionController;
class IndexController extends AbstractActionController {
public function indexAction() {
$objWriter = \PHPExcel_IOFactory::createWriter($modelService->getExcel()/*returns a PHPExcel object*/, 'Excel2007');
ob_start();
$objWriter->save('php://output');