2017 © Pedro Peláez
 

library task

The task logic, parsing, and formatting functionality of Gravitask.

image

gravitask/task

The task logic, parsing, and formatting functionality of Gravitask.

  • Thursday, September 8, 2016
  • by danbartram
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 13 % Grown

The README.md

gravitask/task

Build Status, (*1)

A seriously powerful library for working with TODO list items and tasks., (*2)

Features

Example

$parser = new Gravitask\Task\Parser\TodoTxtParser();

$input = "(A) Write the README file";
$task = $parser->parse($input);

$task->getPriority(); // Result: "A"
$task->getTask(); // Result: "Write the README file"

Installation

The recommended way to install this library is via Composer:, (*3)

composer require gravitask/task

Requirements

  • PHP >= 5.4

TaskItem

This class is the "task object" and holds all of the information about the task, such as its creation date, priority, description, etc., (*4)

Constants

Name Definition
STATUS_ACTIVE The status of the task is active - i.e. in progress, not completed.
STATUS_COMPLETED The status of the task is completed.

Methods

setTask($task)

Set the name/description of the task to be completed., (*5)

Example
$taskItem->setTask("Make another coffee");

getTask()

Retrieve the name/description of the task., (*6)

Example
$task->getTask();
// "Make another coffee"

setContexts(array $contexts)

Set the task's contexts to the items provided in the $contexts array., (*7)

Example
$contexts = ['email', 'computer'];
$task->setContexts($contexts);

addContext($context)

Append a single context item to the pre-existing array of contexts., (*8)

Example
$contexts = ['email'];
$task->setContexts($contexts);

$task->addContext('computer');

getContexts()

Retrieve an array of the task's contexts., (*9)

Example
$contexts = ['email', 'computer'];
$task->setContexts($contexts);

$task->getContexts();
// ['email', 'computer']

setProjects(array $projects)

Set the task's projects to the items provided in the $projects array., (*10)

Example
$projects = ['SecretProject'];
$task->setProjects($projects);

addProject($project)

Append a single project item to the pre-existing array of projects., (*11)

Example
$projects = ['SecretProject'];
$task->setProjects($projects);

$task->addProject('Work');

getProjects()

Retrieve an array of the task's projects., (*12)

Example
$projects = ['SecretProject'];

$task->setProjects($projects);
$task->addProject('Work');

$task->getProjects();
// ['SecretProject', 'Work']

setCreationDate(\DateTime $date)

Set the task's optional creation date., (*13)

The $date argument is a DateTime object set to the required date and time., (*14)

Example
$creationDate = new \DateTime::createFromFormat("Y-m-d", "2016-08-16");
$task->setCreationDate($creaionDate);

getCreationDate()

Retrieve the optional creation date value for the task., (*15)

Example
$task->getCreationDate();
// \DateTime object

setCompletionDate(\DateTime $date)

Set the date of when the task was completed., (*16)

The $date argument is a DateTime object set to the required date and time., (*17)

$task->setStatus(TaskItem::STATUS_COMPLETED);
$completionDate = new \DateTime::createFromFormat("Y-m-d", "2016-08-20");
$task->setCompletionDate($completionDate);

getCompletionDate()

Retrieve the date that the task was completed., (*18)

Example
$task->setStatus(TaskItem::STATUS_COMPLETED);
$completionDate = new \DateTime::createFromFormat("Y-m-d", "2016-08-20");
$task->setCompletionDate($completionDate);

$task->getCompletionDate()
// \DateTime object

setPriority($priority)

Set the task's priority to the provided uppercase single letter of the alphabet. A signifies the highest priority, whilst Z represents the lowest., (*19)

Example
$task->setPriority("B");

getPriority()

Retrieve the task's priority value represented by a single, uppercase letter of the alphabet., (*20)

Example
$task->setPriority("F");

$task->getPriority();
// "F"

setStatus($status)

Set the status of the task to a different value., (*21)

Requirements: * You should ONLY use the values provided as TaskItem constants beginning with STATUS_., (*22)

Example
$task->setStatus(TaskItem::STATUS_COMPLETED);

getStatus()

Retrieve the current status of the task. By default this value will be TaskItem::STATUS_ACTIVE., (*23)

Example
$task->setStatus(TaskItem::STATUS_COMPLETED);

$task->getStatus();
// Integer value representation of the status ENUM.

Formatters

Required Methods

All formatters MUST implement the Gravitask\Task\Formatter\FormatterInterface., (*24)

format(TaskItem $taskItem)

Format the provided TaskItem using the preferred formatter class, e.g. TodoTxtFormatter., (*25)

Example
$task->setPriority("A");
$task->setTask("Write example code");

$formatter = new Gravitask\Task\Formatter\TodoTxtFormatter();

$output = $formatter->format($task);
// "(A) Write example code"

Parsers

Required Methods

All parsers MUST implement the Gravitask\Task\Parser\ParserInterface., (*26)

parse($input)

Parse the provided $input variable and return a Gravitask\Task\TaskItem object, or FALSE on failure to parse., (*27)

Example
$parser = new Gravitask\Task\Parser\TodoTxtParser();

$input = "(A) Write the README file";
$task = $parser->parse($input);

$task->getPriority(); // Result: "A"
$task->getTask(); // Result: "Write the README file"

The Versions

08/09 2016

dev-master

9999999-dev

The task logic, parsing, and formatting functionality of Gravitask.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Dan Bartram

parse todo todo.txt todotxt

31/08 2016

0.1.0

0.1.0.0

The task logic, parsing, and formatting functionality of Gravitask.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Dan Bartram

parse todo todo.txt todotxt