\assignment

An interface to the assignment table in the database

Summary

Methods
Properties
Constants
__construct()
getId()
getOfferId()
getOffer()
getTitle()
setTitle()
getDescription()
setDescription()
getHours()
setHours()
getPricePerHour()
setPricePerHour()
getVAT()
setVAT()
calculate()
delete()
No public properties found
SUBTOTAL
VAT
TOTAL
No protected methods found
$pdo
$offerId
$id
$title
$description
$hours
$price_per_hour
$vat
N/A
No private methods found
No private properties found
N/A

Constants

SUBTOTAL

SUBTOTAL

VAT

VAT

TOTAL

TOTAL

Properties

$pdo

$pdo : \pdo

Type

\pdo — The PDO class for database communication

$offerId

$offerId : \pdo

Type

\pdo — The PDO class for database communication

$id

$id : \pdo

Type

\pdo — The PDO class for database communication

$title

$title : \pdo

Type

\pdo — The PDO class for database communication

$description

$description : \pdo

Type

\pdo — The PDO class for database communication

$hours

$hours : \pdo

Type

\pdo — The PDO class for database communication

$price_per_hour

$price_per_hour : \pdo

Type

\pdo — The PDO class for database communication

$vat

$vat : \pdo

Type

\pdo — The PDO class for database communication

Methods

__construct()

__construct(\PDO  $pdo, integer  $id) 

Create a new instance

Parameters

\PDO $pdo

The PDO class, to access the database

integer $id

The id of the assignment to fetch

Throws

\PDOException

If something went wrong with the database

\Exception

If the assignment could not be found

getId()

getId() : integer

Get the ID of the assignment

Returns

integer —

The ID

getOfferId()

getOfferId() : integer

Get the ID of the offer that this assignment is linked to

Returns

integer —

The ID

getOffer()

getOffer() : \offer

Get the offer that this assignment is linked to

Returns

\offer

The offer

getTitle()

getTitle() : string

Get the title of the assignment

Returns

string —

The title

setTitle()

setTitle(string  $title) : boolean

Set the title of the assignment

Parameters

string $title

The new title for the assignment

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on succes, false on failure

getDescription()

getDescription(boolean  $parseMarkdown = true) : string

Get the description of the assignment

Parameters

boolean $parseMarkdown

Whether or not to parse markdown

Returns

string —

The description

setDescription()

setDescription(string  $description) : boolean

Set the description of the assignment

Parameters

string $description

The new description for the assignment

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on succes, false on failure

getHours()

getHours() : integer

Get the amount of hours of the assignment

Returns

integer —

The amount of hours

setHours()

setHours(integer  $hours) : boolean

Set the amount of hours of the assignment

Parameters

integer $hours

The new amount hours for the assignment

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on succes, false on failure

getPricePerHour()

getPricePerHour() : float

Get the price per hour of the assignment

Returns

float —

The price per hour

setPricePerHour()

setPricePerHour(float  $price_per_hour) : boolean

Set the price per hour of the assignment

Parameters

float $price_per_hour

The new price per hour for the assignment

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on succes, false on failure

getVAT()

getVAT() : float

Get the VAT percentage of the assignment

Returns

float —

The VAT percentage

setVAT()

setVAT(float  $vat) : boolean

Set the VAT percentage of the assignment

Parameters

float $vat

The new VAT percentage for the assignment

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on succes, false on failure

calculate()

calculate(integer  $what = self::TOTAL, integer  $round = 2, boolean  $format = true) : float|boolean

Calculate useful numbers about the assignment

Subtotal: price_per_hour * hours

VAT: subtotal * VAT_percentage

Total: subtotal + VAT

Parameters

integer $what

Any of assignment::SUBTOTAL, assignment::VAT, assignment::TOTAL

integer $round

How many decimals to round on

boolean $format

Whether to format the number nicely (for output) or not (for calculations)

Throws

\PDOException

If something went wrong with the database

Returns

float|boolean —

The calculated value rounded on $round decimals, or false when the input is incorrect

delete()

delete() : boolean

Remove this assignment from the database

If this doesn't succeed (i.e. false is returned), that means the assignment was removed manually or by another instance of this class

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on success, false on failure