| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Fubhy\GraphQL\Language; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | abstract class Node | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |     const KIND_NAME = 'Name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |     const KIND_DOCUMENT = 'Document'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     const KIND_OPERATION_DEFINITION = 'OperationDefinition'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |     const KIND_VARIABLE_DEFINITION = 'VariableDefinition'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     const KIND_VARIABLE = 'Variable'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     const KIND_SELECTION_SET = 'SelectionSet'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     const KIND_FIELD = 'Field'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     const KIND_ARGUMENT = 'Argument'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     const KIND_FRAGMENT_SPREAD = 'FragmentSpread'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     const KIND_INLINE_FRAGMENT = 'InlineFragment'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     const KIND_FRAGMENT_DEFINITION = 'FragmentDefinition'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     const KIND_INT_VALUE = 'IntValue'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     const KIND_FLOAT_VALUE = 'FloatValue'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     const KIND_STRING_VALUE = 'StringValue'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     const KIND_BOOLEAN_VALUE = 'BooleanValue'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     const KIND_ENUM_VALUE = 'EnumValue'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     const KIND_ARRAY_VALUE = 'ArrayValue'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     const KIND_OBJECT_VALUE = 'ObjectValue'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     const KIND_OBJECT_FIELD = 'ObjectField'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     const KIND_DIRECTIVE = 'Directive'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     const KIND_TYPE = 'Type'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     const KIND_LIST_TYPE = 'ListType'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     const KIND_NAMED_TYPE = 'NamedType'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     const KIND_NON_NULL_TYPE = 'NonNullType'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     const KIND = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * @var \Fubhy\GraphQL\Language\Location|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     protected $location; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     protected $attributes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * Constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * @param \Fubhy\GraphQL\Language\Location|null $location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @param array $attributes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 309 |  |     public function __construct(Location $location = NULL, array $attributes = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 309 |  |         $this->location = $location; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 309 |  |         $this->attributes = $attributes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 309 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * @return Location|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     public function getLocation() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         return $this->location; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @param string $key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     public function has($key) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         return array_key_exists($key, $this->attributes); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      * @param string $key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      * @param null $default | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 306 |  |     public function get($key, $default = NULL) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 | 306 |  |         if (array_key_exists($key, $this->attributes)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 306 |  |             return $this->attributes[$key]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         return $default; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      * @param string $key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |      * @param mixed $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     public function set($key, $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         $this->attributes[$key] = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |      * @return string | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 103 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 104 |  |  |     public function __toString() | 
            
                                                        
            
                                    
            
            
                | 105 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 106 |  |  |         return json_encode($this); | 
            
                                                        
            
                                    
            
            
                | 107 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 108 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 109 |  |  |  |