1: <?php
2:
3:
4: namespace BeerXML\Generator;
5:
6:
7: class Recipe extends Record
8: {
9: protected $tagName = 'RECIPE';
10:
11: 12: 13:
14: protected $record;
15:
16: 17: 18: 19: 20:
21: protected $simpleValues = array(
22: 'NAME' => 'getName',
23: 'VERSION' => 'getVersion',
24: 'BREWER' => 'getBrewer',
25: 'BATCH_SIZE' => 'getBatchSize',
26: 'BOIL_SIZE' => 'getBoilSize',
27: 'BOIL_TIME' => 'getBoilTime',
28: );
29:
30: 31: 32: 33: 34:
35: protected $optionalSimpleValues = array(
36: 'ASST_BREWER' => 'getAsstBrewer',
37: 'NOTES' => 'getNotes',
38: 'TASTE_NOTES' => 'getTasteNotes',
39: 'TASTE_RATING' => 'getTasteRating',
40: 'OG' => 'getOg',
41: 'FG' => 'getFg',
42: 'FERMENTATION_STAGES' => 'getFermentationStages',
43: 'PRIMARY_AGE' => 'getPrimaryAge',
44: 'PRIMARY_TEMP' => 'getPrimaryTemp',
45: 'SECONDARY_AGE' => 'getSecondaryAge',
46: 'SECONDARY_TEMP' => 'getSecondaryTemp',
47: 'TERTIARY_AGE' => 'getTertiaryAge',
48: 'TERTIARY_TEMP' => 'getTertiaryTemp',
49: 'AGE' => 'getAge',
50: 'AGE_TEMP' => 'getAgeTemp',
51: 'CARBONATION' => 'getCarbonation',
52: 'PRIMING_SUGAR_NAME' => 'getPrimingSugarName',
53: 'CARBONATION_TEMP' => 'getCarbonationTemp',
54: 'PRIMING_SUGAR_EQUIV' => 'getPrimingSugarEquiv',
55: 'KEG_PRIMING_FACTOR' => 'getKegPrimingFactor',
56: );
57:
58: protected $complexValues = array(
59: 'BeerXML\Generator\Style' => 'getStyle',
60: 'BeerXML\Generator\MashProfile' => 'getMash',
61: );
62:
63: protected $complexValueSets = array(
64: 'HOPS' => array('generator' => 'BeerXML\Generator\Hop', 'values' => 'getHops'),
65: 'FERMENTABLES' => array('generator' => 'BeerXML\Generator\Fermentable', 'values' => 'getFermentables'),
66: 'MISCS' => array('generator' => 'BeerXML\Generator\Misc', 'values' => 'getMiscs'),
67: 'YEASTS' => array('generator' => 'BeerXML\Generator\Yeast', 'values' => 'getYeasts'),
68: 'WATERS' => array('generator' => 'BeerXML\Generator\Water', 'values' => 'getWaters'),
69: );
70:
71: protected $displayInterface = 'BeerXML\Generator\IRecipeDisplay';
72:
73: protected $displayValues = array(
74: 'EST_OG' => 'getEstOg',
75: 'EST_FG' => 'getEstFg',
76: 'EST_COLOR' => 'getEstColor',
77: 'IBU' => 'getIbu',
78: 'IBU_METHOD' => 'getIbuMethod',
79: 'EST_ABV' => 'getEstAbv',
80: 'ABV' => 'getAbv',
81: 'ACTUAL_EFFICIENCY' => 'getActualEfficiency',
82: 'CALORIES' => 'getCalories',
83: 'DISPLAY_BATCH_SIZE' => 'getDisplayBatchSize',
84: 'DISPLAY_BOIL_SIZE' => 'getDisplayBoilSize',
85: 'DISPLAY_OG' => 'getDisplayOg',
86: 'DISPLAY_FG' => 'getDisplayFg',
87: 'DISPLAY_PRIMARY_TEMP' => 'getDisplayPrimaryTemp',
88: 'DISPLAY_SECONDARY_TEMP' => 'getDisplaySecondaryTemp',
89: 'DISPLAY_TERTIARY_TEMP' => 'getDisplayTertiaryTemp',
90: 'DISPLAY_AGE_TEMP' => 'getDisplayAgeTemp',
91: 'CARBONATION_USED' => 'getCarbonationUsed',
92: 'DISPLAY_CARB_TEMP' => 'getDisplayCarbTemp',
93: );
94:
95: 96: 97:
98: protected function additionalFields()
99: {
100: $efficiency = $this->record->getEfficiency();
101: if (!empty($efficiency) ||
102: \BeerXML\Record\Recipe::TYPE_ALL_GRAIN == $this->record->getType() ||
103: \BeerXML\Record\Recipe::TYPE_PARTIAL_MASH == $this->record->getType()
104: ) {
105: $this->xmlWriter->writeElement('EFFICIENCY', $efficiency);
106: }
107:
108: if ($forcedCarb = $this->record->getForcedCarbonation()) {
109: $this->xmlWriter->writeElement('FORCED_CARBONATION', $this->boolToString($forcedCarb));
110: }
111:
112: $date = $this->record->getDate();
113: if ($date instanceof \DateTime) {
114: $this->xmlWriter->writeElement('DATE', $date->format('d M y'));
115: }
116:
117: parent::additionalFields();
118: }
119:
120:
121: }