so tedious string concatenation can be avoided
require("CitationBuilder.php");
use \CitationBuilder\CitationBuilder;
$spec = {@title}{, by @author}{, @co_author}{, published by @publisher{, @publication_year}};
$data = array(
'title' => 'A Brief History of Time'
'author' => 'Stephen Hawking',
'co_author' => NULL,
'publisher' => 'Bantam',
'publication_year' => '1998'
);
$cb = new CitationBuilder($spec, $data);
$citation = $cb->build();
Output:
"A Brief History of Time, by Stephen Hawking, published by Bantam, 1998"
-
Spec
{@title}{, by @author}{, @co_author}{, published by @publisher{, @publication_year}}
-
Segements
{@title} {, by @author} {, @co_author} {, published by @publisher{, @publication_year}} {, @publication_year}
-
Tokens
@title @author @co_author @publisher @publication_year
-
Keys
title author co_author publisher @publication_year
-
Data
array( 'title' => 'A Brief History of Time' 'author' => 'Stephen Hawking', 'co_author' => NULL, 'publisher' => 'Bantam', 'publication_year' => '1998' );
-
Relationships
-
Managed Segments
KEY title MANAGES {@title} SEGMENT, if title doesn't have a textual value in DATA, then the whole SEGEMENT is omitted by the builder
-
Nested Segments
SEGMENT {, published by @publisher{, @publication_year}} is NESTED
In which KEY publisher manages the outer SEGMENT and KEY publication_year manages the inner SEGMENT
-