From 46198a89ccc8e6750a37e1b9127f57238242fadf Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 1 Aug 2016 14:11:06 +0200 Subject: Array shorthands --- classes/Client.php | 4 ++-- classes/Contact.php | 2 +- classes/Correspondence.php | 2 +- classes/Offer.php | 24 ++++++++++++------------ classes/Response.php | 2 +- include/home.php | 22 +++++++++++----------- include/offers-view.php | 16 ++++++++-------- index.php | 4 ++-- nav.php | 6 +++--- 9 files changed, 41 insertions(+), 41 deletions(-) diff --git a/classes/Client.php b/classes/Client.php index 0f0a2f8..1f04f21 100644 --- a/classes/Client.php +++ b/classes/Client.php @@ -79,7 +79,7 @@ class Client extends Model { */ public function createContact($name, $email, $address, $address_2, $postal_code, $city, $country) { $stmt = $this->pdo->prepare("INSERT INTO `".Constants::db_prefix."contact` (`clientId`,`name`,`email`,`address`,`address_2`,`postal_code`,`city`,`country`) VALUES (?,?,?,?,?,?,?,?)"); - $stmt->execute(array( + $stmt->execute([ $this->id, $name, $email, @@ -88,7 +88,7 @@ class Client extends Model { $postal_code, $city, $country - )); + ]); if ($stmt->rowCount() == 1) { return new Contact($this->pdo, $this->pdo->lastInsertId()); } else { diff --git a/classes/Contact.php b/classes/Contact.php index 7689ef7..bf816ea 100644 --- a/classes/Contact.php +++ b/classes/Contact.php @@ -65,7 +65,7 @@ class Contact extends Model { */ public function createOffer() { $stmt = $this->pdo->prepare("INSERT INTO `".Constants::db_prefix."offer` (`contactId`) VALUES (?)"); - $stmt->execute(array($this->id)); + $stmt->execute([$this->id]); if ($stmt->rowCount() == 1) { return new Offer($this->pdo, $this->pdo->lastInsertId()); } else { diff --git a/classes/Correspondence.php b/classes/Correspondence.php index 1c965df..7e5c9ae 100644 --- a/classes/Correspondence.php +++ b/classes/Correspondence.php @@ -241,7 +241,7 @@ class Correspondence extends FPDF { * @param string $lang The language, two letter code ('en', 'nl', ...) */ function SetLangauge($lang) { - $supported = array('nl', 'en'); + $supported = ['nl', 'en']; if (!in_array($lang, $supported)) { throw new Exception("Language not supported"); } else { diff --git a/classes/Offer.php b/classes/Offer.php index 8da2095..1422721 100644 --- a/classes/Offer.php +++ b/classes/Offer.php @@ -282,14 +282,14 @@ class Offer extends Model{ */ public function createAssignment($title, $description, $hours, $price_per_hour, $vat) { $stmt = $this->pdo->prepare("INSERT INTO `".Constants::db_prefix."assignment` (`offerId`,`title`,`description`,`hours`,`price_per_hour`,`VAT_percentage`) VALUES (?,?,?,?,?,?)"); - $stmt->execute(array( + $stmt->execute([ $this->id, $title, $description, $hours, $price_per_hour, $vat - )); + ]); if ($stmt->rowCount() == 1) { return new Assignment($this->pdo, $this->pdo->lastInsertId()); } else { @@ -313,13 +313,13 @@ class Offer extends Model{ */ public function createDiscount($title, $description, $value, $vat) { $stmt = $this->pdo->prepare("INSERT INTO `".Constants::db_prefix."discount` (`offerId`,`title`,`description`,`value`,`VAT_percentage`) VALUES (?,?,?,?,?)"); - $stmt->execute(array( + $stmt->execute([ $this->id, $title, $description, $value, $vat - )); + ]); if ($stmt->rowCount() == 1) { return new Discount($this->pdo, $this->pdo->lastInsertId()); } else { @@ -372,24 +372,24 @@ class Offer extends Model{ $this->invoice_fileId = $file->id; } else { - $invoice_nr = str_replace(array('invoice-','.pdf'), array('',''), $file->filename); + $invoice_nr = str_replace(['invoice-','.pdf'], ['', ''], $file->filename); } - $list = array(); + $list = []; foreach ($this->getAssignments() as $assignment) - $list[] = array( + $list[] = [ $assignment->title, $assignment->price_per_hour * $assignment->hours, $assignment->VAT_percentage . "%", $assignment->price_per_hour * $assignment->hours * (1 + $assignment->VAT_percentage / 100) - ); + ]; foreach ($this->getDiscounts() as $discount) - $list[] = array( + $list[] = [ $discount->title, $discount->calculate(Calculatable::SUBTOTAL), $discount->VAT_percentage . "%", $discount->calculate(Calculatable::TOTAL) - ); + ]; $pdf = new Correspondence(); $pdf->SetContact($this->getContact()); @@ -404,9 +404,9 @@ class Offer extends Model{ $pdf->SetTextColor(0); $pdf->Ln(); - $width = array(90,25,20,25); + $width = [90, 25, 20, 25]; $subtotal = 0; - $btw = array(); + $btw = []; $total = 0; // Header diff --git a/classes/Response.php b/classes/Response.php index f37b6e9..ffb3e20 100644 --- a/classes/Response.php +++ b/classes/Response.php @@ -34,7 +34,7 @@ class Response { * Create a new instance */ public function __construct() { - $this->response = array(); + $this->response = []; $this->http_response_code = 200; } diff --git a/include/home.php b/include/home.php index b42ec8e..05846cf 100644 --- a/include/home.php +++ b/include/home.php @@ -155,7 +155,7 @@ require('./header.php');
= CURDATE()"]); - $list = array(); + $list = []; foreach ($offers as $offer) { $start = BusinessAdmin::formatDate($offer->start_date, false); $end = BusinessAdmin::formatDate($offer->end_date, false); @@ -166,7 +166,7 @@ require('./header.php'); // We want to sort on percentage (DESC) and secondly end date (ASC) so start date (DESC) $base = str_pad($percentage, 3, '0', STR_PAD_LEFT) . $offer->start_date; for ($i = 0; isset($list["$base-$i"]); $i++); - $list["$base-$i"] = array( + $list["$base-$i"] = [ 'start' => $start, 'end' => $end, 'id' => $offer->id, @@ -174,7 +174,7 @@ require('./header.php'); 'percentage' => $percentage, 'price_excl' => Constants::invoice_valuta . $offer->calculate(Calculatable::SUBTOTAL), 'price_incl' => Constants::invoice_valuta . $offer->calculate(Calculatable::TOTAL) - ); + ]; } krsort($list, SORT_STRING); foreach ($list as $item) { @@ -301,28 +301,28 @@ require('./header.php');