Overview

Namespaces

  • BeerXML
    • Exception
    • Generator
    • Parser
    • Record
  • PHP

Classes

  • Equipment
  • Fermentable
  • Hop
  • MashProfile
  • MashStep
  • Misc
  • Recipe
  • Record
  • RecordFactory
  • Style
  • Water
  • Yeast

Interfaces

  • IEquipment
  • IEquipmentDisplay
  • IFermentable
  • IFermentableDisplay
  • IHop
  • IHopDisplay
  • IMashProfile
  • IMashProfileDisplay
  • IMashStep
  • IMashStepDisplay
  • IMisc
  • IMiscDisplay
  • IRecipe
  • IRecipeDisplay
  • IStyle
  • IStyleDisplay
  • IWater
  • IWaterDisplay
  • IYeast
  • IYeastDisplay
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: 
 4: namespace BeerXML\Parser;
 5: 
 6: 
 7: use BeerXML\Exception\BadData;
 8: 
 9: class Recipe extends Record
10: {
11:     protected $tagName = 'RECIPE';
12: 
13:     /**
14:      * Tags that map to simple values and the corresponding setter method on the record class
15:      *
16:      * @var array
17:      */
18:     protected $simpleProperties = array(
19:         'AGE'                 => 'setAge',
20:         'AGE_TEMP'            => 'setAgeTemp',
21:         'ASST_BREWER'         => 'setAsstBrewer',
22:         'BATCH_SIZE'          => 'setBatchSize',
23:         'BOIL_SIZE'           => 'setBoilSize',
24:         'BOIL_TIME'           => 'setBoilTime',
25:         'BREWER'              => 'setBrewer',
26:         'CARBONATION'         => 'setCarbonation',
27:         'CARBONATION_TEMP'    => 'setCarbonationTemp',
28:         'EFFICIENCY'          => 'setEfficiency',
29:         'FERMENTATION_STAGES' => 'setFermentationStages',
30:         'FG'                  => 'setFg',
31:         'KEG_PRIMING_FACTOR'  => 'setKegPrimingFactor',
32:         'NAME'                => 'setName',
33:         'NOTES'               => 'setNotes',
34:         'OG'                  => 'setOg',
35:         'PRIMARY_AGE'         => 'setPrimaryAge',
36:         'PRIMARY_TEMP'        => 'setPrimaryTemp',
37:         'PRIMING_SUGAR_EQUIV' => 'setPrimingSugarEquiv',
38:         'PRIMING_SUGAR_NAME'  => 'setPrimingSugarName',
39:         'SECONDARY_AGE'       => 'setSecondaryAge',
40:         'SECONDARY_TEMP'      => 'setSecondaryTemp',
41:         'TASTE_NOTES'         => 'setTasteNotes',
42:         'TASTE_RATING'        => 'setTasteRating',
43:         'TERTIARY_AGE'        => 'setTertiaryAge',
44:         'TERTIARY_TEMP'       => 'setTertiaryTemp',
45:         'TYPE'                => 'setType',
46:         'VERSION'             => 'setVersion',
47:     );
48: 
49:     /**
50:      * @return IRecipe
51:      */
52:     protected function createRecord()
53:     {
54:         $recipe = $this->recordFactory->getRecipe();
55:         if ($recipe instanceof IRecipeDisplay) {
56:             $this->simpleProperties = array_merge(
57:                 $this->simpleProperties,
58:                 array(
59:                     'EST_OG'                 => 'setEstOg',
60:                     'EST_FG'                 => 'setEstFg',
61:                     'EST_COLOR'              => 'setEstColor',
62:                     'IBU'                    => 'setIbu',
63:                     'IBU_METHOD'             => 'setIbuMethod',
64:                     'EST_ABV'                => 'setEstAbv',
65:                     'ABV'                    => 'setAbv',
66:                     'ACTUAL_EFFICIENCY'      => 'setActualEfficiency',
67:                     'CALORIES'               => 'setCalories',
68:                     'DISPLAY_BATCH_SIZE'     => 'setDisplayBatchSize',
69:                     'DISPLAY_BOIL_SIZE'      => 'setDisplayBoilSize',
70:                     'DISPLAY_OG'             => 'setDisplayOg',
71:                     'DISPLAY_FG'             => 'setDisplayFg',
72:                     'DISPLAY_PRIMARY_TEMP'   => 'setDisplayPrimaryTemp',
73:                     'DISPLAY_SECONDARY_TEMP' => 'setDisplaySecondaryTemp',
74:                     'DISPLAY_TERTIARY_TEMP'  => 'setDisplayTertiaryTemp',
75:                     'DISPLAY_AGE_TEMP'       => 'setDisplayAgeTemp',
76:                     'CARBONATION_USED'       => 'setCarbonationUsed',
77:                     'DISPLAY_CARB_TEMP'      => 'setDisplayCarbTemp',
78:                 )
79:             );
80:         }
81:         return $recipe;
82:     }
83: 
84:     /**
85:      * @param IRecipe $record
86:      */
87:     protected function otherElementEncountered($record)
88:     {
89:         if ('FORCED_CARBONATION' == $this->xmlReader->name) {
90:             $carb = ($this->xmlReader->readString() == 'TRUE');
91:             $record->setForcedCarbonation($carb);
92:         } elseif ('DATE' == $this->xmlReader->name) {
93:             $date = new \DateTime($this->xmlReader->readString());
94:             $record->setDate($date);
95:         }
96:     }
97: }
98: 
php-beerxml API documentation generated by ApiGen 2.8.0