Compare commits

...

14 Commits
master ... dev

Author SHA1 Message Date
Cerys Lewis 0a9f77f82f just a bit of tidying, nowt exciting 3 months ago
Cerys Lewis a1a7c69b5d committing what i've got before going home lol 4 months ago
Cerys Lewis a62ed0667e Delete QueryResponseWrapper.php 4 months ago
Cerys Lewis f0de6b3702 aligning 4 months ago
Cerys Lewis 72c714dc56 `DELETE` query 4 months ago
Cerys Lewis 50934994a6 `GRANT` and `SELECT` examples now shadow the deegraph docs 4 months ago
Cerys Lewis 1cd138b3bd returns proper constructors 4 months ago
Cerys Lewis b1055d3148 aligning 4 months ago
Cerys Lewis bab993ba06 trying to tidy up the code 4 months ago
Cerys Lewis 1cce3a14d9 started the move over to much more "builder" style 4 months ago
Cerys Lewis af9cdb7cdf function to get Actor 4 months ago
Cerys Lewis 4a1e8da97e updated the regex 4 months ago
Cerys Lewis 841a433ded better handing for different responses 4 months ago
Cerys Lewis 0a8d60c18a made a start on the GRANT query 4 months ago
  1. 819
      .editorconfig
  2. 11
      examples/connection.php
  3. 21
      examples/deleteQuery.php
  4. 40
      examples/grantQuery.php
  5. 42
      examples/selectQuery.php
  6. 41
      examples/test.php
  7. 41
      src/Attributes/QueryBuilderQuery.php
  8. 6
      src/Attributes/QueryBuilderRequiredField.php
  9. 61
      src/Core/DeegraphServer.php
  10. 35
      src/DataStructures/DataURL.php
  11. 2
      src/DataStructures/KeyValuePair.php
  12. 13
      src/DataStructures/QueryResponseRow.php
  13. 36
      src/DataStructures/QueryResponseWrapper.php
  14. 4
      src/DataStructures/ServerInfo.php
  15. 2
      src/Enumerators/DeegraphEqualityOperator.php
  16. 2
      src/Enumerators/DeegraphNumericalComparator.php
  17. 11
      src/Enumerators/DeegraphPermissionType.php
  18. 14
      src/Enumerators/HTTPMethod.php
  19. 7
      src/Exceptions/QueryBuilderConflictingFieldAlreadyExistsException.php
  20. 7
      src/Exceptions/QueryBuilderInvalidDeegraphPathException.php
  21. 7
      src/Exceptions/QueryBuilderInvalidInputException.php
  22. 7
      src/Exceptions/QueryBuilderRequiredFieldIsNotSetException.php
  23. 15
      src/Interfaces/QueryBuilderInterface.php
  24. 23
      src/Interfaces/QueryInstanceInterface.php
  25. 8
      src/Interfaces/QueryResponseInterface.php
  26. 25
      src/QueryBuilder/QueryBuilder.php
  27. 29
      src/QueryBuilder/QueryBuilderTrait.php
  28. 42
      src/QueryBuilder/QueryBuilders/DeleteQueryBuilder.php
  29. 84
      src/QueryBuilder/QueryBuilders/GrantQueryBuilder.php
  30. 84
      src/QueryBuilder/QueryBuilders/InsertQuery.php
  31. 81
      src/QueryBuilder/QueryBuilders/InsertQueryBuilder.php
  32. 113
      src/QueryBuilder/QueryBuilders/PutQuery.php
  33. 117
      src/QueryBuilder/QueryBuilders/PutQueryBuilder.php
  34. 42
      src/QueryBuilder/QueryBuilders/SelectQueryBuilder.php
  35. 23
      src/QueryInstance/DeleteQuery.php
  36. 22
      src/QueryInstance/GrantQuery.php
  37. 22
      src/QueryInstance/InsertQuery.php
  38. 22
      src/QueryInstance/PutQuery.php
  39. 22
      src/QueryInstance/SelectQuery.php
  40. 13
      src/QueryResponse/DeleteQueryResponse.php
  41. 17
      src/QueryResponse/GrantQueryResponse.php
  42. 13
      src/QueryResponse/InsertQueryResponse.php
  43. 14
      src/QueryResponse/PutQueryResponse.php
  44. 44
      src/QueryResponse/SelectQueryResponse.php
  45. 33
      src/Superclasses/QueryInstanceSuperclass.php
  46. 86
      src/Traits/QueryBuilderTrait.php
  47. 13
      tests/QueryBuilderPutTest.php

819
.editorconfig

@ -0,0 +1,819 @@
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = false
max_line_length = 120
tab_width = 4
ij_continuation_indent_size = 8
ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on
ij_formatter_tags_enabled = true
ij_smart_tabs = false
ij_visual_guides =
ij_wrap_on_typing = false
[*.blade.php]
ij_blade_keep_indents_on_empty_lines = false
[*.css]
ij_css_align_closing_brace_with_properties = false
ij_css_blank_lines_around_nested_selector = 1
ij_css_blank_lines_between_blocks = 1
ij_css_block_comment_add_space = false
ij_css_brace_placement = end_of_line
ij_css_enforce_quotes_on_format = false
ij_css_hex_color_long_format = false
ij_css_hex_color_lower_case = false
ij_css_hex_color_short_format = false
ij_css_hex_color_upper_case = false
ij_css_keep_blank_lines_in_code = 2
ij_css_keep_indents_on_empty_lines = false
ij_css_keep_single_line_blocks = false
ij_css_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow
ij_css_space_after_colon = true
ij_css_space_before_opening_brace = true
ij_css_use_double_quotes = true
ij_css_value_alignment = do_not_align
[*.feature]
indent_size = 2
ij_gherkin_keep_indents_on_empty_lines = false
[*.less]
indent_size = 2
ij_less_align_closing_brace_with_properties = false
ij_less_blank_lines_around_nested_selector = 1
ij_less_blank_lines_between_blocks = 1
ij_less_block_comment_add_space = false
ij_less_brace_placement = 0
ij_less_enforce_quotes_on_format = false
ij_less_hex_color_long_format = false
ij_less_hex_color_lower_case = false
ij_less_hex_color_short_format = false
ij_less_hex_color_upper_case = false
ij_less_keep_blank_lines_in_code = 2
ij_less_keep_indents_on_empty_lines = false
ij_less_keep_single_line_blocks = false
ij_less_line_comment_add_space = false
ij_less_line_comment_at_first_column = false
ij_less_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow
ij_less_space_after_colon = true
ij_less_space_before_opening_brace = true
ij_less_use_double_quotes = true
ij_less_value_alignment = 0
[*.sass]
indent_size = 2
ij_sass_align_closing_brace_with_properties = false
ij_sass_blank_lines_around_nested_selector = 1
ij_sass_blank_lines_between_blocks = 1
ij_sass_brace_placement = 0
ij_sass_enforce_quotes_on_format = false
ij_sass_hex_color_long_format = false
ij_sass_hex_color_lower_case = false
ij_sass_hex_color_short_format = false
ij_sass_hex_color_upper_case = false
ij_sass_keep_blank_lines_in_code = 2
ij_sass_keep_indents_on_empty_lines = false
ij_sass_keep_single_line_blocks = false
ij_sass_line_comment_add_space = false
ij_sass_line_comment_at_first_column = false
ij_sass_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow
ij_sass_space_after_colon = true
ij_sass_space_before_opening_brace = true
ij_sass_use_double_quotes = true
ij_sass_value_alignment = 0
[*.scss]
indent_size = 2
ij_scss_align_closing_brace_with_properties = false
ij_scss_blank_lines_around_nested_selector = 1
ij_scss_blank_lines_between_blocks = 1
ij_scss_block_comment_add_space = false
ij_scss_brace_placement = 0
ij_scss_enforce_quotes_on_format = false
ij_scss_hex_color_long_format = false
ij_scss_hex_color_lower_case = false
ij_scss_hex_color_short_format = false
ij_scss_hex_color_upper_case = false
ij_scss_keep_blank_lines_in_code = 2
ij_scss_keep_indents_on_empty_lines = false
ij_scss_keep_single_line_blocks = false
ij_scss_line_comment_add_space = false
ij_scss_line_comment_at_first_column = false
ij_scss_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow
ij_scss_space_after_colon = true
ij_scss_space_before_opening_brace = true
ij_scss_use_double_quotes = true
ij_scss_value_alignment = 0
[*.twig]
ij_twig_keep_indents_on_empty_lines = false
ij_twig_spaces_inside_comments_delimiters = true
ij_twig_spaces_inside_delimiters = true
ij_twig_spaces_inside_variable_delimiters = true
[*.vue]
indent_size = 2
tab_width = 2
ij_continuation_indent_size = 4
ij_vue_indent_children_of_top_level = template
ij_vue_interpolation_new_line_after_start_delimiter = true
ij_vue_interpolation_new_line_before_end_delimiter = true
ij_vue_interpolation_wrap = off
ij_vue_keep_indents_on_empty_lines = false
ij_vue_spaces_within_interpolation_expressions = true
[.editorconfig]
ij_editorconfig_align_group_field_declarations = false
ij_editorconfig_space_after_colon = false
ij_editorconfig_space_after_comma = true
ij_editorconfig_space_before_colon = false
ij_editorconfig_space_before_comma = false
ij_editorconfig_spaces_around_assignment_operators = true
[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.rng,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul,phpunit.xml.dist}]
ij_xml_align_attributes = true
ij_xml_align_text = false
ij_xml_attribute_wrap = normal
ij_xml_block_comment_add_space = false
ij_xml_block_comment_at_first_column = true
ij_xml_keep_blank_lines = 2
ij_xml_keep_indents_on_empty_lines = false
ij_xml_keep_line_breaks = true
ij_xml_keep_line_breaks_in_text = true
ij_xml_keep_whitespaces = false
ij_xml_keep_whitespaces_around_cdata = preserve
ij_xml_keep_whitespaces_inside_cdata = false
ij_xml_line_comment_at_first_column = true
ij_xml_space_after_tag_name = false
ij_xml_space_around_equals_in_attribute = false
ij_xml_space_inside_empty_tag = false
ij_xml_text_wrap = normal
[{*.ats,*.cts,*.mts,*.ts}]
ij_continuation_indent_size = 4
ij_typescript_align_imports = false
ij_typescript_align_multiline_array_initializer_expression = false
ij_typescript_align_multiline_binary_operation = false
ij_typescript_align_multiline_chained_methods = false
ij_typescript_align_multiline_extends_list = false
ij_typescript_align_multiline_for = true
ij_typescript_align_multiline_parameters = true
ij_typescript_align_multiline_parameters_in_calls = false
ij_typescript_align_multiline_ternary_operation = false
ij_typescript_align_object_properties = 0
ij_typescript_align_union_types = false
ij_typescript_align_var_statements = 0
ij_typescript_array_initializer_new_line_after_left_brace = false
ij_typescript_array_initializer_right_brace_on_new_line = false
ij_typescript_array_initializer_wrap = off
ij_typescript_assignment_wrap = off
ij_typescript_binary_operation_sign_on_next_line = false
ij_typescript_binary_operation_wrap = off
ij_typescript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/**
ij_typescript_blank_lines_after_imports = 1
ij_typescript_blank_lines_around_class = 1
ij_typescript_blank_lines_around_field = 0
ij_typescript_blank_lines_around_field_in_interface = 0
ij_typescript_blank_lines_around_function = 1
ij_typescript_blank_lines_around_method = 1
ij_typescript_blank_lines_around_method_in_interface = 1
ij_typescript_block_brace_style = end_of_line
ij_typescript_block_comment_add_space = false
ij_typescript_block_comment_at_first_column = true
ij_typescript_call_parameters_new_line_after_left_paren = false
ij_typescript_call_parameters_right_paren_on_new_line = false
ij_typescript_call_parameters_wrap = off
ij_typescript_catch_on_new_line = false
ij_typescript_chained_call_dot_on_new_line = true
ij_typescript_class_brace_style = end_of_line
ij_typescript_comma_on_new_line = false
ij_typescript_do_while_brace_force = never
ij_typescript_else_on_new_line = false
ij_typescript_enforce_trailing_comma = keep
ij_typescript_enum_constants_wrap = on_every_item
ij_typescript_extends_keyword_wrap = off
ij_typescript_extends_list_wrap = off
ij_typescript_field_prefix = _
ij_typescript_file_name_style = relaxed
ij_typescript_finally_on_new_line = false
ij_typescript_for_brace_force = never
ij_typescript_for_statement_new_line_after_left_paren = false
ij_typescript_for_statement_right_paren_on_new_line = false
ij_typescript_for_statement_wrap = off
ij_typescript_force_quote_style = false
ij_typescript_force_semicolon_style = false
ij_typescript_function_expression_brace_style = end_of_line
ij_typescript_if_brace_force = never
ij_typescript_import_merge_members = global
ij_typescript_import_prefer_absolute_path = global
ij_typescript_import_sort_members = true
ij_typescript_import_sort_module_name = false
ij_typescript_import_use_node_resolution = true
ij_typescript_imports_wrap = on_every_item
ij_typescript_indent_case_from_switch = true
ij_typescript_indent_chained_calls = true
ij_typescript_indent_package_children = 0
ij_typescript_jsdoc_include_types = false
ij_typescript_jsx_attribute_value = braces
ij_typescript_keep_blank_lines_in_code = 2
ij_typescript_keep_first_column_comment = true
ij_typescript_keep_indents_on_empty_lines = false
ij_typescript_keep_line_breaks = true
ij_typescript_keep_simple_blocks_in_one_line = false
ij_typescript_keep_simple_methods_in_one_line = false
ij_typescript_line_comment_add_space = true
ij_typescript_line_comment_at_first_column = false
ij_typescript_method_brace_style = end_of_line
ij_typescript_method_call_chain_wrap = off
ij_typescript_method_parameters_new_line_after_left_paren = false
ij_typescript_method_parameters_right_paren_on_new_line = false
ij_typescript_method_parameters_wrap = off
ij_typescript_object_literal_wrap = on_every_item
ij_typescript_object_types_wrap = on_every_item
ij_typescript_parentheses_expression_new_line_after_left_paren = false
ij_typescript_parentheses_expression_right_paren_on_new_line = false
ij_typescript_place_assignment_sign_on_next_line = false
ij_typescript_prefer_as_type_cast = false
ij_typescript_prefer_explicit_types_function_expression_returns = false
ij_typescript_prefer_explicit_types_function_returns = false
ij_typescript_prefer_explicit_types_vars_fields = false
ij_typescript_prefer_parameters_wrap = false
ij_typescript_property_prefix =
ij_typescript_reformat_c_style_comments = false
ij_typescript_space_after_colon = true
ij_typescript_space_after_comma = true
ij_typescript_space_after_dots_in_rest_parameter = false
ij_typescript_space_after_generator_mult = true
ij_typescript_space_after_property_colon = true
ij_typescript_space_after_quest = true
ij_typescript_space_after_type_colon = true
ij_typescript_space_after_unary_not = false
ij_typescript_space_before_async_arrow_lparen = true
ij_typescript_space_before_catch_keyword = true
ij_typescript_space_before_catch_left_brace = true
ij_typescript_space_before_catch_parentheses = true
ij_typescript_space_before_class_lbrace = true
ij_typescript_space_before_class_left_brace = true
ij_typescript_space_before_colon = true
ij_typescript_space_before_comma = false
ij_typescript_space_before_do_left_brace = true
ij_typescript_space_before_else_keyword = true
ij_typescript_space_before_else_left_brace = true
ij_typescript_space_before_finally_keyword = true
ij_typescript_space_before_finally_left_brace = true
ij_typescript_space_before_for_left_brace = true
ij_typescript_space_before_for_parentheses = true
ij_typescript_space_before_for_semicolon = false
ij_typescript_space_before_function_left_parenth = true
ij_typescript_space_before_generator_mult = false
ij_typescript_space_before_if_left_brace = true
ij_typescript_space_before_if_parentheses = true
ij_typescript_space_before_method_call_parentheses = false
ij_typescript_space_before_method_left_brace = true
ij_typescript_space_before_method_parentheses = false
ij_typescript_space_before_property_colon = false
ij_typescript_space_before_quest = true
ij_typescript_space_before_switch_left_brace = true
ij_typescript_space_before_switch_parentheses = true
ij_typescript_space_before_try_left_brace = true
ij_typescript_space_before_type_colon = false
ij_typescript_space_before_unary_not = false
ij_typescript_space_before_while_keyword = true
ij_typescript_space_before_while_left_brace = true
ij_typescript_space_before_while_parentheses = true
ij_typescript_spaces_around_additive_operators = true
ij_typescript_spaces_around_arrow_function_operator = true
ij_typescript_spaces_around_assignment_operators = true
ij_typescript_spaces_around_bitwise_operators = true
ij_typescript_spaces_around_equality_operators = true
ij_typescript_spaces_around_logical_operators = true
ij_typescript_spaces_around_multiplicative_operators = true
ij_typescript_spaces_around_relational_operators = true
ij_typescript_spaces_around_shift_operators = true
ij_typescript_spaces_around_unary_operator = false
ij_typescript_spaces_within_array_initializer_brackets = false
ij_typescript_spaces_within_brackets = false
ij_typescript_spaces_within_catch_parentheses = false
ij_typescript_spaces_within_for_parentheses = false
ij_typescript_spaces_within_if_parentheses = false
ij_typescript_spaces_within_imports = false
ij_typescript_spaces_within_interpolation_expressions = false
ij_typescript_spaces_within_method_call_parentheses = false
ij_typescript_spaces_within_method_parentheses = false
ij_typescript_spaces_within_object_literal_braces = false
ij_typescript_spaces_within_object_type_braces = true
ij_typescript_spaces_within_parentheses = false
ij_typescript_spaces_within_switch_parentheses = false
ij_typescript_spaces_within_type_assertion = false
ij_typescript_spaces_within_union_types = true
ij_typescript_spaces_within_while_parentheses = false
ij_typescript_special_else_if_treatment = true
ij_typescript_ternary_operation_signs_on_next_line = false
ij_typescript_ternary_operation_wrap = off
ij_typescript_union_types_wrap = on_every_item
ij_typescript_use_chained_calls_group_indents = false
ij_typescript_use_double_quotes = true
ij_typescript_use_explicit_js_extension = auto
ij_typescript_use_import_type = auto
ij_typescript_use_path_mapping = always
ij_typescript_use_public_modifier = false
ij_typescript_use_semicolon_after_statement = true
ij_typescript_var_declaration_wrap = normal
ij_typescript_while_brace_force = never
ij_typescript_while_on_new_line = false
ij_typescript_wrap_comments = false
[{*.bash,*.sh,*.zsh}]
indent_size = 2
tab_width = 2
ij_shell_binary_ops_start_line = false
ij_shell_keep_column_alignment_padding = false
ij_shell_minify_program = false
ij_shell_redirect_followed_by_space = false
ij_shell_switch_cases_indented = false
ij_shell_use_unix_line_separator = true
[{*.cjs,*.js}]
ij_continuation_indent_size = 4
ij_javascript_align_imports = false
ij_javascript_align_multiline_array_initializer_expression = false
ij_javascript_align_multiline_binary_operation = false
ij_javascript_align_multiline_chained_methods = false
ij_javascript_align_multiline_extends_list = false
ij_javascript_align_multiline_for = true
ij_javascript_align_multiline_parameters = true
ij_javascript_align_multiline_parameters_in_calls = false
ij_javascript_align_multiline_ternary_operation = false
ij_javascript_align_object_properties = 0
ij_javascript_align_union_types = false
ij_javascript_align_var_statements = 0
ij_javascript_array_initializer_new_line_after_left_brace = false
ij_javascript_array_initializer_right_brace_on_new_line = false
ij_javascript_array_initializer_wrap = off
ij_javascript_assignment_wrap = off
ij_javascript_binary_operation_sign_on_next_line = false
ij_javascript_binary_operation_wrap = off
ij_javascript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/**
ij_javascript_blank_lines_after_imports = 1
ij_javascript_blank_lines_around_class = 1
ij_javascript_blank_lines_around_field = 0
ij_javascript_blank_lines_around_function = 1
ij_javascript_blank_lines_around_method = 1
ij_javascript_block_brace_style = end_of_line
ij_javascript_block_comment_add_space = false
ij_javascript_block_comment_at_first_column = true
ij_javascript_call_parameters_new_line_after_left_paren = false
ij_javascript_call_parameters_right_paren_on_new_line = false
ij_javascript_call_parameters_wrap = off
ij_javascript_catch_on_new_line = false
ij_javascript_chained_call_dot_on_new_line = true
ij_javascript_class_brace_style = end_of_line
ij_javascript_comma_on_new_line = false
ij_javascript_do_while_brace_force = never
ij_javascript_else_on_new_line = false
ij_javascript_enforce_trailing_comma = keep
ij_javascript_extends_keyword_wrap = off
ij_javascript_extends_list_wrap = off
ij_javascript_field_prefix = _
ij_javascript_file_name_style = relaxed
ij_javascript_finally_on_new_line = false
ij_javascript_for_brace_force = never
ij_javascript_for_statement_new_line_after_left_paren = false
ij_javascript_for_statement_right_paren_on_new_line = false
ij_javascript_for_statement_wrap = off
ij_javascript_force_quote_style = false
ij_javascript_force_semicolon_style = false
ij_javascript_function_expression_brace_style = end_of_line
ij_javascript_if_brace_force = never
ij_javascript_import_merge_members = global
ij_javascript_import_prefer_absolute_path = global
ij_javascript_import_sort_members = true
ij_javascript_import_sort_module_name = false
ij_javascript_import_use_node_resolution = true
ij_javascript_imports_wrap = on_every_item
ij_javascript_indent_case_from_switch = true
ij_javascript_indent_chained_calls = true
ij_javascript_indent_package_children = 0
ij_javascript_jsx_attribute_value = braces
ij_javascript_keep_blank_lines_in_code = 2
ij_javascript_keep_first_column_comment = true
ij_javascript_keep_indents_on_empty_lines = false
ij_javascript_keep_line_breaks = true
ij_javascript_keep_simple_blocks_in_one_line = false
ij_javascript_keep_simple_methods_in_one_line = false
ij_javascript_line_comment_add_space = true
ij_javascript_line_comment_at_first_column = false
ij_javascript_method_brace_style = end_of_line
ij_javascript_method_call_chain_wrap = off
ij_javascript_method_parameters_new_line_after_left_paren = false
ij_javascript_method_parameters_right_paren_on_new_line = false
ij_javascript_method_parameters_wrap = off
ij_javascript_object_literal_wrap = on_every_item
ij_javascript_object_types_wrap = on_every_item
ij_javascript_parentheses_expression_new_line_after_left_paren = false
ij_javascript_parentheses_expression_right_paren_on_new_line = false
ij_javascript_place_assignment_sign_on_next_line = false
ij_javascript_prefer_as_type_cast = false
ij_javascript_prefer_explicit_types_function_expression_returns = false
ij_javascript_prefer_explicit_types_function_returns = false
ij_javascript_prefer_explicit_types_vars_fields = false
ij_javascript_prefer_parameters_wrap = false
ij_javascript_property_prefix =
ij_javascript_reformat_c_style_comments = false
ij_javascript_space_after_colon = true
ij_javascript_space_after_comma = true
ij_javascript_space_after_dots_in_rest_parameter = false
ij_javascript_space_after_generator_mult = true
ij_javascript_space_after_property_colon = true
ij_javascript_space_after_quest = true
ij_javascript_space_after_type_colon = true
ij_javascript_space_after_unary_not = false
ij_javascript_space_before_async_arrow_lparen = true
ij_javascript_space_before_catch_keyword = true
ij_javascript_space_before_catch_left_brace = true
ij_javascript_space_before_catch_parentheses = true
ij_javascript_space_before_class_lbrace = true
ij_javascript_space_before_class_left_brace = true
ij_javascript_space_before_colon = true
ij_javascript_space_before_comma = false
ij_javascript_space_before_do_left_brace = true
ij_javascript_space_before_else_keyword = true
ij_javascript_space_before_else_left_brace = true
ij_javascript_space_before_finally_keyword = true
ij_javascript_space_before_finally_left_brace = true
ij_javascript_space_before_for_left_brace = true
ij_javascript_space_before_for_parentheses = true
ij_javascript_space_before_for_semicolon = false
ij_javascript_space_before_function_left_parenth = true
ij_javascript_space_before_generator_mult = false
ij_javascript_space_before_if_left_brace = true
ij_javascript_space_before_if_parentheses = true
ij_javascript_space_before_method_call_parentheses = false
ij_javascript_space_before_method_left_brace = true
ij_javascript_space_before_method_parentheses = false
ij_javascript_space_before_property_colon = false
ij_javascript_space_before_quest = true
ij_javascript_space_before_switch_left_brace = true
ij_javascript_space_before_switch_parentheses = true
ij_javascript_space_before_try_left_brace = true
ij_javascript_space_before_type_colon = false
ij_javascript_space_before_unary_not = false
ij_javascript_space_before_while_keyword = true
ij_javascript_space_before_while_left_brace = true
ij_javascript_space_before_while_parentheses = true
ij_javascript_spaces_around_additive_operators = true
ij_javascript_spaces_around_arrow_function_operator = true
ij_javascript_spaces_around_assignment_operators = true
ij_javascript_spaces_around_bitwise_operators = true
ij_javascript_spaces_around_equality_operators = true
ij_javascript_spaces_around_logical_operators = true
ij_javascript_spaces_around_multiplicative_operators = true
ij_javascript_spaces_around_relational_operators = true
ij_javascript_spaces_around_shift_operators = true
ij_javascript_spaces_around_unary_operator = false
ij_javascript_spaces_within_array_initializer_brackets = false
ij_javascript_spaces_within_brackets = false
ij_javascript_spaces_within_catch_parentheses = false
ij_javascript_spaces_within_for_parentheses = false
ij_javascript_spaces_within_if_parentheses = false
ij_javascript_spaces_within_imports = false
ij_javascript_spaces_within_interpolation_expressions = false
ij_javascript_spaces_within_method_call_parentheses = false
ij_javascript_spaces_within_method_parentheses = false
ij_javascript_spaces_within_object_literal_braces = false
ij_javascript_spaces_within_object_type_braces = true
ij_javascript_spaces_within_parentheses = false
ij_javascript_spaces_within_switch_parentheses = false
ij_javascript_spaces_within_type_assertion = false
ij_javascript_spaces_within_union_types = true
ij_javascript_spaces_within_while_parentheses = false
ij_javascript_special_else_if_treatment = true
ij_javascript_ternary_operation_signs_on_next_line = false
ij_javascript_ternary_operation_wrap = off
ij_javascript_union_types_wrap = on_every_item
ij_javascript_use_chained_calls_group_indents = false
ij_javascript_use_double_quotes = true
ij_javascript_use_explicit_js_extension = auto
ij_javascript_use_import_type = auto
ij_javascript_use_path_mapping = always
ij_javascript_use_public_modifier = false
ij_javascript_use_semicolon_after_statement = true
ij_javascript_var_declaration_wrap = normal
ij_javascript_while_brace_force = never
ij_javascript_while_on_new_line = false
ij_javascript_wrap_comments = false
[{*.ctp,*.hphp,*.inc,*.module,*.php,*.php4,*.php5,*.phtml}]
ij_continuation_indent_size = 4
ij_php_align_assignments = true
ij_php_align_class_constants = false
ij_php_align_enum_cases = false
ij_php_align_group_field_declarations = false
ij_php_align_inline_comments = false
ij_php_align_key_value_pairs = false
ij_php_align_match_arm_bodies = false
ij_php_align_multiline_array_initializer_expression = false
ij_php_align_multiline_binary_operation = false
ij_php_align_multiline_chained_methods = false
ij_php_align_multiline_extends_list = false
ij_php_align_multiline_for = true
ij_php_align_multiline_parameters = true
ij_php_align_multiline_parameters_in_calls = false
ij_php_align_multiline_ternary_operation = true
ij_php_align_named_arguments = false
ij_php_align_phpdoc_comments = true
ij_php_align_phpdoc_param_names = true
ij_php_anonymous_brace_style = next_line
ij_php_api_weight = 28
ij_php_array_initializer_new_line_after_left_brace = false
ij_php_array_initializer_right_brace_on_new_line = false
ij_php_array_initializer_wrap = off
ij_php_assignment_wrap = off
ij_php_attributes_wrap = off
ij_php_author_weight = 28
ij_php_binary_operation_sign_on_next_line = false
ij_php_binary_operation_wrap = off
ij_php_blank_lines_after_class_header = 0
ij_php_blank_lines_after_function = 1
ij_php_blank_lines_after_imports = 1
ij_php_blank_lines_after_opening_tag = 0
ij_php_blank_lines_after_package = 0
ij_php_blank_lines_around_class = 1
ij_php_blank_lines_around_constants = 0
ij_php_blank_lines_around_enum_cases = 0
ij_php_blank_lines_around_field = 0
ij_php_blank_lines_around_method = 1
ij_php_blank_lines_before_class_end = 0
ij_php_blank_lines_before_imports = 1
ij_php_blank_lines_before_method_body = 0
ij_php_blank_lines_before_package = 1
ij_php_blank_lines_before_return_statement = 0
ij_php_blank_lines_between_imports = 0
ij_php_block_brace_style = next_line
ij_php_call_parameters_new_line_after_left_paren = false
ij_php_call_parameters_right_paren_on_new_line = false
ij_php_call_parameters_wrap = off
ij_php_catch_on_new_line = false
ij_php_category_weight = 28
ij_php_class_brace_style = next_line
ij_php_comma_after_last_argument = true
ij_php_comma_after_last_array_element = false
ij_php_comma_after_last_closure_use_var = false
ij_php_comma_after_last_match_arm = false
ij_php_comma_after_last_parameter = false
ij_php_concat_spaces = true
ij_php_copyright_weight = 28
ij_php_deprecated_weight = 28
ij_php_do_while_brace_force = never
ij_php_else_if_style = combine
ij_php_else_on_new_line = false
ij_php_example_weight = 28
ij_php_extends_keyword_wrap = off
ij_php_extends_list_wrap = off
ij_php_fields_default_visibility = private
ij_php_filesource_weight = 28
ij_php_finally_on_new_line = false
ij_php_for_brace_force = never
ij_php_for_statement_new_line_after_left_paren = false
ij_php_for_statement_right_paren_on_new_line = false
ij_php_for_statement_wrap = off
ij_php_force_empty_methods_in_one_line = false
ij_php_force_short_declaration_array_style = false
ij_php_getters_setters_naming_style = camel_case
ij_php_getters_setters_order_style = getters_first
ij_php_global_weight = 28
ij_php_group_use_wrap = on_every_item
ij_php_if_brace_force = never
ij_php_if_lparen_on_next_line = false
ij_php_if_rparen_on_next_line = false
ij_php_ignore_weight = 28
ij_php_import_sorting = alphabetic
ij_php_indent_break_from_case = true
ij_php_indent_case_from_switch = true
ij_php_indent_code_in_php_tags = false
ij_php_internal_weight = 28
ij_php_keep_blank_lines_after_lbrace = 2
ij_php_keep_blank_lines_before_right_brace = 2
ij_php_keep_blank_lines_in_code = 2
ij_php_keep_blank_lines_in_declarations = 2
ij_php_keep_control_statement_in_one_line = true
ij_php_keep_first_column_comment = true
ij_php_keep_indents_on_empty_lines = false
ij_php_keep_line_breaks = true
ij_php_keep_rparen_and_lbrace_on_one_line = false
ij_php_keep_simple_classes_in_one_line = true
ij_php_keep_simple_methods_in_one_line = true
ij_php_lambda_brace_style = next_line
ij_php_license_weight = 28
ij_php_line_comment_add_space = false
ij_php_line_comment_at_first_column = true
ij_php_link_weight = 28
ij_php_lower_case_boolean_const = true
ij_php_lower_case_keywords = true
ij_php_lower_case_null_const = true
ij_php_method_brace_style = next_line
ij_php_method_call_chain_wrap = off
ij_php_method_parameters_new_line_after_left_paren = false
ij_php_method_parameters_right_paren_on_new_line = false
ij_php_method_parameters_wrap = off
ij_php_method_weight = 28
ij_php_modifier_list_wrap = false
ij_php_multiline_chained_calls_semicolon_on_new_line = false
ij_php_namespace_brace_style = 2
ij_php_new_line_after_php_opening_tag = true
ij_php_null_type_position = in_the_end
ij_php_package_weight = 28
ij_php_param_weight = 0
ij_php_parameters_attributes_wrap = off
ij_php_parentheses_expression_new_line_after_left_paren = false
ij_php_parentheses_expression_right_paren_on_new_line = false
ij_php_phpdoc_blank_line_before_tags = true
ij_php_phpdoc_blank_lines_around_parameters = true
ij_php_phpdoc_keep_blank_lines = true
ij_php_phpdoc_param_spaces_between_name_and_description = 1
ij_php_phpdoc_param_spaces_between_tag_and_type = 1
ij_php_phpdoc_param_spaces_between_type_and_name = 1
ij_php_phpdoc_use_fqcn = false
ij_php_phpdoc_wrap_long_lines = false
ij_php_place_assignment_sign_on_next_line = false
ij_php_place_parens_for_constructor = 0
ij_php_property_read_weight = 28
ij_php_property_weight = 28
ij_php_property_write_weight = 28
ij_php_return_type_on_new_line = false
ij_php_return_weight = 1
ij_php_see_weight = 28
ij_php_since_weight = 28
ij_php_sort_phpdoc_elements = true
ij_php_space_after_colon = true
ij_php_space_after_colon_in_enum_backed_type = true
ij_php_space_after_colon_in_named_argument = true
ij_php_space_after_colon_in_return_type = true
ij_php_space_after_comma = true
ij_php_space_after_for_semicolon = true
ij_php_space_after_quest = true
ij_php_space_after_type_cast = false
ij_php_space_after_unary_not = false
ij_php_space_before_array_initializer_left_brace = false
ij_php_space_before_catch_keyword = true
ij_php_space_before_catch_left_brace = true
ij_php_space_before_catch_parentheses = false
ij_php_space_before_class_left_brace = true
ij_php_space_before_closure_left_parenthesis = false
ij_php_space_before_colon = true
ij_php_space_before_colon_in_enum_backed_type = false
ij_php_space_before_colon_in_named_argument = false
ij_php_space_before_colon_in_return_type = false
ij_php_space_before_comma = false
ij_php_space_before_do_left_brace = true
ij_php_space_before_else_keyword = true
ij_php_space_before_else_left_brace = true
ij_php_space_before_finally_keyword = true
ij_php_space_before_finally_left_brace = true
ij_php_space_before_for_left_brace = true
ij_php_space_before_for_parentheses = false
ij_php_space_before_for_semicolon = false
ij_php_space_before_if_left_brace = true
ij_php_space_before_if_parentheses = false
ij_php_space_before_method_call_parentheses = false
ij_php_space_before_method_left_brace = true
ij_php_space_before_method_parentheses = false
ij_php_space_before_quest = true
ij_php_space_before_short_closure_left_parenthesis = false
ij_php_space_before_switch_left_brace = true
ij_php_space_before_switch_parentheses = false
ij_php_space_before_try_left_brace = true
ij_php_space_before_unary_not = false
ij_php_space_before_while_keyword = true
ij_php_space_before_while_left_brace = true
ij_php_space_before_while_parentheses = false
ij_php_space_between_ternary_quest_and_colon = false
ij_php_spaces_around_additive_operators = true
ij_php_spaces_around_arrow = false
ij_php_spaces_around_assignment_in_declare = false
ij_php_spaces_around_assignment_operators = true
ij_php_spaces_around_bitwise_operators = true
ij_php_spaces_around_equality_operators = true
ij_php_spaces_around_logical_operators = true
ij_php_spaces_around_multiplicative_operators = true
ij_php_spaces_around_null_coalesce_operator = true
ij_php_spaces_around_pipe_in_union_type = false
ij_php_spaces_around_relational_operators = true
ij_php_spaces_around_shift_operators = true
ij_php_spaces_around_unary_operator = false
ij_php_spaces_around_var_within_brackets = false
ij_php_spaces_within_array_initializer_braces = false
ij_php_spaces_within_brackets = false
ij_php_spaces_within_catch_parentheses = false
ij_php_spaces_within_for_parentheses = false
ij_php_spaces_within_if_parentheses = false
ij_php_spaces_within_method_call_parentheses = false
ij_php_spaces_within_method_parentheses = false
ij_php_spaces_within_parentheses = false
ij_php_spaces_within_short_echo_tags = true
ij_php_spaces_within_switch_parentheses = false
ij_php_spaces_within_while_parentheses = false
ij_php_special_else_if_treatment = false
ij_php_subpackage_weight = 28
ij_php_ternary_operation_signs_on_next_line = false
ij_php_ternary_operation_wrap = off
ij_php_throws_weight = 2
ij_php_todo_weight = 28
ij_php_treat_multiline_arrays_and_lambdas_multiline = false
ij_php_unknown_tag_weight = 28
ij_php_upper_case_boolean_const = false
ij_php_upper_case_null_const = false
ij_php_uses_weight = 28
ij_php_var_weight = 28
ij_php_variable_naming_style = mixed
ij_php_version_weight = 28
ij_php_while_brace_force = never
ij_php_while_on_new_line = false
[{*.har,*.jsb2,*.jsb3,*.json,*.jsonc,*.postman_collection,*.postman_collection.json,*.postman_environment,*.postman_environment.json,.babelrc,.eslintrc,.prettierrc,.stylelintrc,.ws-context,bowerrc,composer.lock,jest.config}]
indent_size = 2
ij_json_array_wrapping = split_into_lines
ij_json_keep_blank_lines_in_code = 0
ij_json_keep_indents_on_empty_lines = false
ij_json_keep_line_breaks = true
ij_json_keep_trailing_comma = false
ij_json_object_wrapping = split_into_lines
ij_json_property_alignment = do_not_align
ij_json_space_after_colon = true
ij_json_space_after_comma = true
ij_json_space_before_colon = false
ij_json_space_before_comma = false
ij_json_spaces_within_braces = false
ij_json_spaces_within_brackets = false
ij_json_wrap_long_lines = false
[{*.htm,*.html,*.sht,*.shtm,*.shtml}]
ij_html_add_new_line_before_tags = body,div,p,form,h1,h2,h3
ij_html_align_attributes = true
ij_html_align_text = false
ij_html_attribute_wrap = normal
ij_html_block_comment_add_space = false
ij_html_block_comment_at_first_column = true
ij_html_do_not_align_children_of_min_lines = 0
ij_html_do_not_break_if_inline_tags = title,h1,h2,h3,h4,h5,h6,p
ij_html_do_not_indent_children_of_tags = html,body,thead,tbody,tfoot
ij_html_enforce_quotes = false
ij_html_inline_tags = a,abbr,acronym,b,basefont,bdo,big,br,cite,cite,code,dfn,em,font,i,img,input,kbd,label,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var
ij_html_keep_blank_lines = 2
ij_html_keep_indents_on_empty_lines = false
ij_html_keep_line_breaks = true
ij_html_keep_line_breaks_in_text = true
ij_html_keep_whitespaces = false
ij_html_keep_whitespaces_inside = span,pre,textarea
ij_html_line_comment_at_first_column = true
ij_html_new_line_after_last_attribute = never
ij_html_new_line_before_first_attribute = never
ij_html_quote_style = double
ij_html_remove_new_line_before_tags = br
ij_html_space_after_tag_name = false
ij_html_space_around_equality_in_attribute = false
ij_html_space_inside_empty_tag = false
ij_html_text_wrap = normal
[{*.http,*.rest}]
indent_size = 0
ij_continuation_indent_size = 4
ij_http-request_call_parameters_wrap = normal
ij_http-request_method_parameters_wrap = split_into_lines
ij_http-request_space_before_comma = true
ij_http-request_spaces_around_assignment_operators = true
[{*.markdown,*.md}]
ij_markdown_force_one_space_after_blockquote_symbol = true
ij_markdown_force_one_space_after_header_symbol = true
ij_markdown_force_one_space_after_list_bullet = true
ij_markdown_force_one_space_between_words = true
ij_markdown_format_tables = true
ij_markdown_insert_quote_arrows_on_wrap = true
ij_markdown_keep_indents_on_empty_lines = false
ij_markdown_keep_line_breaks_inside_text_blocks = true
ij_markdown_max_lines_around_block_elements = 1
ij_markdown_max_lines_around_header = 1
ij_markdown_max_lines_between_paragraphs = 1
ij_markdown_min_lines_around_block_elements = 1
ij_markdown_min_lines_around_header = 1
ij_markdown_min_lines_between_paragraphs = 1
ij_markdown_wrap_text_if_long = true
ij_markdown_wrap_text_inside_blockquotes = true
[{*.yaml,*.yml}]
indent_size = 2
ij_yaml_align_values_properties = do_not_align
ij_yaml_autoinsert_sequence_marker = true
ij_yaml_block_mapping_on_new_line = false
ij_yaml_indent_sequence_value = true
ij_yaml_keep_indents_on_empty_lines = false
ij_yaml_keep_line_breaks = true
ij_yaml_sequence_on_new_line = false
ij_yaml_space_before_colon = false
ij_yaml_spaces_within_braces = true
ij_yaml_spaces_within_brackets = true

11
examples/connection.php

@ -0,0 +1,11 @@
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use Darksparrow\DeegraphInteractions\Core\DeegraphServer;
$db = new DeegraphServer(
token: "UFVUX1lPVVJfVE9LRU5fSEVSRQ==",
actor: "db36576b-cc5c-573a-8ae2-00258884d8c6",
allowSelfSignedCerts: true,
);

21
examples/deleteQuery.php

@ -0,0 +1,21 @@
<?php
// https://github.com/owoalex/deegraph/blob/main/docs/query-delete.md#examples
global $db;
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../examples/connection.php';
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilder;
use Darksparrow\DeegraphInteractions\QueryInstance\DeleteQuery;
function Example0(): DeleteQuery
{
$queryBuilder = QueryBuilder::Delete()
->RelativePath(relativePath: "");
return $queryBuilder->Build();
}
$result = Example0()->RunQuery($db);
var_dump($result);

40
examples/grantQuery.php

@ -0,0 +1,40 @@
<?php
// https://github.com/owoalex/deegraph/blob/main/docs/query-grant.md#examples
global $db;
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../examples/connection.php';
use Darksparrow\DeegraphInteractions\Enumerators\DeegraphPermissionType;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilder;
use Darksparrow\DeegraphInteractions\QueryInstance\GrantQuery;
function Example0(): GrantQuery
{
$queryBuilder = QueryBuilder::Grant()
->Permissions(permissionTypes: [
DeegraphPermissionType::WRITE,
DeegraphPermissionType::READ,
])
->On(target: "*")
->IsDelegatable();
return $queryBuilder->Build();
}
function Example1(): GrantQuery
{
$queryBuilder = QueryBuilder::Grant()
->Permissions(permissionTypes: [
DeegraphPermissionType::WRITE,
DeegraphPermissionType::READ,
])
->On(target: "*")
->IsDelegatable();
return $queryBuilder->Build();
}
$result = Example0()->RunQuery($db);
var_dump($result);

42
examples/selectQuery.php

@ -0,0 +1,42 @@
<?php
// https://github.com/owoalex/deegraph/blob/main/docs/query-select.md#examples
global $db;
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../examples/connection.php';
use Darksparrow\DeegraphInteractions\Enumerators\DeegraphEqualityOperator;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\SelectQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryInstance\SelectQuery;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilder;
function Example0(): SelectQuery
{
$queryBuilder = QueryBuilder::Select()
->RelativePath(relativePath: ".")
->Where(target: "name", operator: DeegraphEqualityOperator::IS, value: "Peter Evans")
->From("**");
return $queryBuilder->Build();
}
function Example1(): SelectQuery
{
$queryBuilder = QueryBuilder::Select()
->RelativePaths(relativePaths: [
"email_address",
"name",
])
->Where(target: "display_name", operator: DeegraphEqualityOperator::IS, value: "Peter")
->From("**")
->InstanceOf(schema: "https://schemas.auxiliumsoftware.co.uk/v1/user.json");
return $queryBuilder->Build();
}
$result = Example0()->RunQuery($db);
foreach($result->FlattenRows() as $row)
{
echo "$row\n";
}

41
examples/test.php

@ -0,0 +1,41 @@
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use Darksparrow\DeegraphInteractions\Core\DeegraphServer;
use Darksparrow\DeegraphInteractions\DataStructures\DataURL;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilder;
$db = new DeegraphServer(
token: "UFVUX1lPVVJfVE9LRU5fSEVSRQ==",
actor: "db36576b-cc5c-573a-8ae2-00258884d8c6",
allowSelfSignedCerts: true,
);
/*
$insertQuery = QueryBuilder::Put()
->Schema(schema: "https://schemas.auxiliumsoftware.co.uk/v1/collection.json")
->At(relativePath: "{970334ed-1f4f-465a-94d7-923a99698786}/todo");
$insertQuery = QueryBuilder::Put()
->URI(uri: DataURL::BuildBase64(unencodedString: "nya~"))
->At(relativePath: "{970334ed-1f4f-465a-94d7-923a99698786}/example");
$insertQuery = QueryBuilder::Insert()
->RelativePath(relativePath: "{970334ed-1f4f-465a-94d7-923a99698786}/example");
echo $insertQuery;
echo "\n";
$result = $db->RunQuery($insertQuery);
var_dump($result);
*/
$selectQueryBuilder = QueryBuilder::Select()
->RelativePath(relativePath: ".")
->From(target: "**");
$selectQuery = $selectQueryBuilder->Build();
$result = $selectQuery->RunQuery($db);
foreach($result->FlattenRows() as $row)
{
echo "$row\n";
}

41
src/Attributes/QueryBuilderQuery.php

@ -2,9 +2,10 @@
namespace Darksparrow\DeegraphInteractions\Attributes;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\InsertQuery;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\PutQuery;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\SelectQuery;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\InsertQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\PutQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\SelectQueryBuilder;
use Exception;
use PhpParser\Node\Attribute;
use PhpParser\Node\Name;
use ReflectionClass;
@ -13,34 +14,10 @@ use ReflectionClass;
{
public function __construct()
{
parent::__construct(new Name("QueryBuilderQuery", []), [], []);
}
public function ValidateValues(
InsertQuery|PutQuery|SelectQuery $target
): void
{
$nameBase = "Darksparrow\\DeegraphPHP\\Attributes";
$reflection = new ReflectionClass($target);
$properties = $reflection->getProperties();
foreach ($properties as $property)
{
$attributes = $property->getAttributes();
$propertyName = $property->getName();
$propertyValue = $property->getValue($target);
if(sizeof($attributes) == 0) continue;
foreach ($attributes as $attribute)
{
if($attribute->getName() == "$nameBase\\QueryBuilderRequiredField")
{
if($propertyValue == "")
throw new \Exception();
}
}
}
parent::__construct(
name: new Name("QueryBuilderQuery", []),
args: [],
attributes: [],
);
}
}

6
src/Attributes/QueryBuilderRequiredField.php

@ -14,6 +14,10 @@ use PhpParser\Node\Name;
)
{
$this->Required = $required;
parent::__construct(new Name("QueryBuilderRequiredField", []), [], []);
parent::__construct(
name: new Name("QueryBuilderRequiredField", []),
args: [],
attributes: [],
);
}
}

61
src/Core/DeegraphServer.php

@ -2,40 +2,44 @@
namespace Darksparrow\DeegraphInteractions\Core;
use Darksparrow\DeegraphInteractions\DataStructures\QueryResponseWrapper;
use Darksparrow\DeegraphInteractions\DataStructures\ServerInfo;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\InsertQuery;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\PutQuery;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\SelectQuery;
use Darksparrow\DeegraphInteractions\Enumerators\HTTPMethod;
use Exception;
class DeegraphServer
final class DeegraphServer
{
private string $Token;
private string $Actor;
protected string $Token;
protected string $Actor;
private string $ServerDomain;
private int $Port;
private bool $AllowSelfSignedCerts;
protected string $ServerDomain;
protected int $Port;
protected bool $AllowSelfSignedCerts;
public function __construct(
string $token,
string $actor,
string $server = "localhost",
int $port = 8088,
bool $allowSelfSignedCerts = false)
int $port = 8088,
bool $allowSelfSignedCerts = false)
{
$this->Token = $token;
$this->Actor = $actor;
$this->ServerDomain = $server;
$this->Port = $port;
$this->ServerDomain = $server;
$this->Port = $port;
$this->AllowSelfSignedCerts = $allowSelfSignedCerts;
}
public function GetActor(): string
{
return $this->Actor;
}
/**
* Runs an API request against the Deegraph Server, and returns back information about the Deegraph Server.
*
* @return ServerInfo
* @throws Exception
*/
public function ServerInfo(): ServerInfo
{
@ -43,7 +47,7 @@ class DeegraphServer
return ServerInfo::FromAPIResponse(response: $response);
}
private function RunRawRequest(string $endpoint, string $method = "GET", string $body = null): string
public function RunRawRequest(string $endpoint, HTTPMethod $method = HTTPMethod::GET, string $body = null): string
{
$ch = curl_init("https://{$this->ServerDomain}:{$this->Port}{$endpoint}");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
@ -53,7 +57,8 @@ class DeegraphServer
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if ($method == "POST") {
if($method == HTTPMethod::POST)
{
curl_setopt($ch, CURLOPT_POST, 1);
}
if($this->AllowSelfSignedCerts)
@ -62,8 +67,10 @@ class DeegraphServer
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
if ($method == "POST" || $method == "PUT") {
if ($body != null) {
if($method == HTTPMethod::POST || $method == HTTPMethod::PUT)
{
if($body != null)
{
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
}
}
@ -72,7 +79,7 @@ class DeegraphServer
if(curl_error($ch) == "SSL certificate problem: unable to get local issuer certificate")
{
throw new \Exception();
throw new Exception();
die();
}
@ -80,18 +87,4 @@ class DeegraphServer
return $result;
}
/**
* @param InsertQuery|PutQuery|SelectQuery $query Takes in a Query Builder object.
* @return QueryResponseWrapper
*/
public function RunQuery(InsertQuery|PutQuery|SelectQuery $query): QueryResponseWrapper
{
$response = $this->RunRawRequest(
endpoint: "/api/v1/@query",
method: "POST",
body: $query
);
return QueryResponseWrapper::FromAPIResponse($response);
}
}

35
src/DataStructures/DataURL.php

@ -0,0 +1,35 @@
<?php
namespace Darksparrow\DeegraphInteractions\DataStructures;
class DataURL
{
private string $Data;
private string $MIMEType;
public function __construct(string $mimeType, string $data)
{
$this->Data = $data;
$this->MIMEType = $mimeType;
}
public static function FromDataURL(string $dataURL): DataURL
{
}
public static function BuildBase64(string $unencodedString): DataURL
{
return new DataURL(mimeType: "text/plain", data: "base64," . base64_encode(string: $unencodedString));
}
public function __toString(): string
{
$builder = "data:";
$builder .= $this->MIMEType;
$builder .= ",";
$builder .= urlencode(string: $this->Data);
return $builder;
}
}

2
src/DataStructures/KeyValuePair.php

@ -9,7 +9,7 @@ class KeyValuePair
public function __construct(string $key, ?string $value)
{
$this->Key = $key;
$this->Key = $key;
$this->Value = $value;
}

13
src/DataStructures/QueryResponseRow.php

@ -7,22 +7,17 @@ class QueryResponseRow
public string $Search;
public array $Results;
public static function FromArray(array $array): QueryResponseRow
public function __construct(array $array)
{
$builder = new QueryResponseRow();
$builder->Search = key(array: $array);
foreach($array["{$builder->Search}"] as $key=>$value)
$this->Search = key(array: $array);
foreach($array["{$this->Search}"] as $key => $value)
{
$builder->Results[] = new KeyValuePair(key: $key, value: $value);
$this->Results[] = new KeyValuePair(key: $key, value: $value);
}
return $builder;
}
public function __toString(): string
{
return json_encode($this, JSON_PRETTY_PRINT);
}
}

36
src/DataStructures/QueryResponseWrapper.php

@ -1,36 +0,0 @@
<?php
namespace Darksparrow\DeegraphInteractions\DataStructures;
class QueryResponseWrapper
{
public array $Rows;
public string $RowFormat;
public static function FromAPIResponse(string $response): QueryResponseWrapper
{
$temp = json_decode($response, true);
$builder = new QueryResponseWrapper();
foreach($temp["@rows"] as $row) $builder->Rows[] = QueryResponseRow::FromArray(array: $row);
$builder->RowFormat = $temp["@row_format"];
return $builder;
}
public function Flatten(): array
{
$builder = [];
foreach($this->Rows as $row)
{
foreach($row->Results as $result)
{
$builder[] = $result;
}
}
return $builder;
}
}

4
src/DataStructures/ServerInfo.php

@ -14,9 +14,9 @@ class ServerInfo
$builder = new ServerInfo();
$builder->InstanceID = $temp["@instance_id"];
$builder->InstanceID = $temp["@instance_id"];
$builder->InstanceFQDN = $temp["@instance_fqdn"];
$builder->PublicKeys = $temp["@public_keys"];
$builder->PublicKeys = $temp["@public_keys"];
return $builder;
}

2
src/Enumerators/DeegraphEqualityOperator.php

@ -9,5 +9,5 @@ enum DeegraphEqualityOperator: string
case IS = "===";
case DIFFERENT = "!=";
case ISNT = "ISNT";
case IS_NOT = "ISNT";
}

2
src/Enumerators/DeegraphNumericalComparator.php

@ -1,6 +1,6 @@
<?php
namespace Darksparrow\DeegraphPHP\Enumerators;
namespace Darksparrow\DeegraphInteractions\Enumerators;
enum DeegraphNumericalComparator: string
{

11
src/Enumerators/DeegraphPermissionType.php

@ -0,0 +1,11 @@
<?php
namespace Darksparrow\DeegraphInteractions\Enumerators;
enum DeegraphPermissionType: string
{
case WRITE = "WRITE";
case READ = "READ";
case DELETE = "DELETE";
case ACT = "ACT";
}

14
src/Enumerators/HTTPMethod.php

@ -0,0 +1,14 @@
<?php
namespace Darksparrow\DeegraphInteractions\Enumerators;
enum HTTPMethod
{
case GET;
case POST;
case PUT;
case DELETE;
}

7
src/Exceptions/QueryBuilderConflictingFieldAlreadyExistsException.php

@ -8,10 +8,11 @@ class QueryBuilderConflictingFieldAlreadyExistsException extends Exception
{
public function __construct(
string $message = "You have tried to set a field which would nullify a field you've previously set.",
int $code = 422
) {
int $code = 422
)
{
parent::__construct($message, $code);
$this->message = "$message";
$this->code = $code;
$this->code = $code;
}
}

7
src/Exceptions/QueryBuilderInvalidDeegraphPathException.php

@ -8,10 +8,11 @@ class QueryBuilderInvalidDeegraphPathException extends Exception
{
public function __construct(
string $message = "The Deegraph path you have entered is not valid.",
int $code = 422
) {
int $code = 422
)
{
parent::__construct($message, $code);
$this->message = "$message";
$this->code = $code;
$this->code = $code;
}
}

7
src/Exceptions/QueryBuilderInvalidInputException.php

@ -8,10 +8,11 @@ class QueryBuilderInvalidInputException extends Exception
{
public function __construct(
string $message = "The value you have entered doesn't pass regex validation.",
int $code = 422
) {
int $code = 422
)
{
parent::__construct($message, $code);
$this->message = "$message";
$this->code = $code;
$this->code = $code;
}
}

7
src/Exceptions/QueryBuilderRequiredFieldIsNotSetException.php

@ -8,10 +8,11 @@ class QueryBuilderRequiredFieldIsNotSetException extends Exception
{
public function __construct(
string $message = "A field that is required for this operation has not been set.",
int $code = 422
) {
int $code = 422
)
{
parent::__construct($message, $code);
$this->message = "$message";
$this->code = $code;
$this->code = $code;
}
}

15
src/Interfaces/QueryBuilderInterface.php

@ -0,0 +1,15 @@
<?php
namespace Darksparrow\DeegraphInteractions\Interfaces;
use Darksparrow\DeegraphInteractions\QueryInstance\DeleteQuery;
use Darksparrow\DeegraphInteractions\QueryInstance\GrantQuery;
use Darksparrow\DeegraphInteractions\QueryInstance\InsertQuery;
use Darksparrow\DeegraphInteractions\QueryInstance\PutQuery;
use Darksparrow\DeegraphInteractions\QueryInstance\SelectQuery;
interface QueryBuilderInterface
{
// public function __construct();
public function Build(): DeleteQuery|GrantQuery|InsertQuery|PutQuery|SelectQuery;
}

23
src/Interfaces/QueryInstanceInterface.php

@ -0,0 +1,23 @@
<?php
namespace Darksparrow\DeegraphInteractions\Interfaces;
use Darksparrow\DeegraphInteractions\Core\DeegraphServer;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\InsertQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryResponse\DeleteQueryResponse;
use Darksparrow\DeegraphInteractions\QueryResponse\GrantQueryResponse;
use Darksparrow\DeegraphInteractions\QueryResponse\InsertQueryResponse;
use Darksparrow\DeegraphInteractions\QueryResponse\PutQueryResponse;
use Darksparrow\DeegraphInteractions\QueryResponse\SelectQueryResponse;
interface QueryInstanceInterface
{
/**
* Runs the Query Instance on a DeegraphServer Instance.
*
* @param DeegraphServer $deegraphServer
*
* @return DeleteQueryResponse|GrantQueryResponse|InsertQueryResponse|PutQueryResponse|SelectQueryResponse
*/
public function RunQuery(DeegraphServer $deegraphServer): mixed;
}

8
src/Interfaces/QueryResponseInterface.php

@ -0,0 +1,8 @@
<?php
namespace Darksparrow\DeegraphInteractions\Interfaces;
interface QueryResponseInterface
{
public function __construct(string $response);
}

25
src/QueryBuilder/QueryBuilder.php

@ -2,22 +2,17 @@
namespace Darksparrow\DeegraphInteractions\QueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\InsertQuery;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\PutQuery;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\SelectQuery;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\DeleteQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\GrantQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\InsertQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\PutQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\SelectQueryBuilder;
final class QueryBuilder
{
public static function Insert(): InsertQuery
{
return new InsertQuery();
}
public static function Put(): PutQuery
{
return new PutQuery();
}
public static function Select(): SelectQuery
{
return new SelectQuery();
}
public static function Delete(): DeleteQueryBuilder { return new DeleteQueryBuilder(); }
public static function Grant(): GrantQueryBuilder { return new GrantQueryBuilder(); }
public static function Insert(): InsertQueryBuilder { return new InsertQueryBuilder(); }
public static function Put(): PutQueryBuilder { return new PutQueryBuilder(); }
public static function Select(): SelectQueryBuilder { return new SelectQueryBuilder(); }
}

29
src/QueryBuilder/QueryBuilderTrait.php

@ -1,29 +0,0 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryBuilder;
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderConflictingFieldAlreadyExistsException;
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderInvalidInputException;
trait QueryBuilderTrait
{
protected function RegexValidate(string $target, string $pattern): string
{
if (!preg_match(pattern: $pattern, subject: $target))
throw new QueryBuilderInvalidInputException();
return $target;
}
protected function EnsureNotSet(string $target): void
{
if ($target != "")
throw new QueryBuilderConflictingFieldAlreadyExistsException();
}
protected function ValidateDeegraphPath(string $target): string
{
if (!preg_match(pattern: "(^(\{[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}\})$)|(^\{[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}\}(\/([a-z][a-z0-9]*|[0-9]+|#|\*))+$)|(^(([a-z][a-z0-9]*|[0-9]+|#|\*))(\/([a-z][a-z0-9]*|[0-9]+|#|\*))*$)", subject: $target))
throw new QueryBuilderInvalidInputException();
return $target;
}
}

42
src/QueryBuilder/QueryBuilders/DeleteQueryBuilder.php

@ -0,0 +1,42 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField;
use Darksparrow\DeegraphInteractions\Enumerators\DeegraphEqualityOperator;
use Darksparrow\DeegraphInteractions\Enumerators\DeegraphPermissionType;
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderRequiredFieldIsNotSetException;
use Darksparrow\DeegraphInteractions\Interfaces\QueryBuilderInterface;
use Darksparrow\DeegraphInteractions\QueryInstance\DeleteQuery;
use Darksparrow\DeegraphInteractions\QueryInstance\GrantQuery;
use Darksparrow\DeegraphInteractions\Traits\QueryBuilderTrait;
#[QueryBuilderQuery]
final class DeleteQueryBuilder implements QueryBuilderInterface
{
use QueryBuilderTrait;
#[QueryBuilderRequiredField]
protected string $RelativePath;
/**
* @throws QueryBuilderRequiredFieldIsNotSetException
*/
public function Build(): DeleteQuery
{
self::ValidateValues($this);
$builder = "DELETE ";
if($this->RelativePath != "") $builder .= $this->RelativePath;
return new DeleteQuery(queryString: $builder);
}
public function RelativePath(string $relativePath): DeleteQueryBuilder
{
$this->RelativePath = $relativePath;
return $this;
}
}

84
src/QueryBuilder/QueryBuilders/GrantQueryBuilder.php

@ -0,0 +1,84 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField;
use Darksparrow\DeegraphInteractions\Enumerators\DeegraphEqualityOperator;
use Darksparrow\DeegraphInteractions\Enumerators\DeegraphPermissionType;
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderRequiredFieldIsNotSetException;
use Darksparrow\DeegraphInteractions\Interfaces\QueryBuilderInterface;
use Darksparrow\DeegraphInteractions\QueryInstance\GrantQuery;
use Darksparrow\DeegraphInteractions\Traits\QueryBuilderTrait;
#[QueryBuilderQuery]
final class GrantQueryBuilder implements QueryBuilderInterface
{
use QueryBuilderTrait;
#[QueryBuilderRequiredField]
protected array $PermissionTypes;
protected string $GrantOn = "";
protected string $GrantWhere = "";
protected bool $GrantDelegatable = false;
/**
* @throws QueryBuilderRequiredFieldIsNotSetException
*/
public function Build(): GrantQuery
{
self::ValidateValues($this);
$builder = "GRANT ";
if(sizeof($this->PermissionTypes)) $builder .= implode(separator: ",", array: $this->PermissionTypes);
if($this->GrantOn != "") $builder .= " ON $this->GrantOn";
if($this->GrantWhere != "") $builder .= " WHERE $this->GrantWhere";
return new GrantQuery(queryString: $builder);
}
public function Permissions(array $permissionTypes): GrantQueryBuilder
{
$this->PermissionTypes = [];
foreach($permissionTypes as $permissionType)
$this->PermissionTypes[] = $permissionType->value;
return $this;
}
public function GrantAll(): GrantQueryBuilder
{
$this->PermissionTypes = [
DeegraphPermissionType::WRITE->value,
DeegraphPermissionType::READ->value,
DeegraphPermissionType::DELETE->value,
DeegraphPermissionType::ACT->value,
];
return $this;
}
public function On(string $target): GrantQueryBuilder
{
$this->GrantOn = $target;
return $this;
}
public function Where(string $target, DeegraphEqualityOperator $operator, string $value): GrantQueryBuilder
{
$this->GrantWhere = "$target $operator->value $value";
return $this;
}
public function IsDelegatable(): GrantQueryBuilder
{
$this->GrantDelegatable = true;
return $this;
}
public function NotDelegatable(): GrantQueryBuilder
{
$this->GrantDelegatable = false;
return $this;
}
}

84
src/QueryBuilder/QueryBuilders/InsertQuery.php

@ -1,84 +0,0 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait;
#[QueryBuilderQuery]
final class InsertQuery
{
use QueryBuilderTrait;
#[QueryBuilderRequiredField]
protected string $RelativePath = "";
protected array $Keys = [];
protected array $Schemas = [];
protected string $Values = "";
protected bool $Duplicate = false;
protected bool $Replace = false;
public function __construct()
{
}
public function __toString(): string
{
$instance = new QueryBuilderQuery();
$instance->ValidateValues($this);
$builder = "INSERT INTO $this->RelativePath";
if(sizeof($this->Keys) > 0) $builder .= "KEYS " . implode(separator: ", ", array: $this->Keys);
if(sizeof($this->Schemas) > 0) $builder .= "SCHEMAS " . implode(separator: ", ", array: $this->Schemas);
if($this->Values != "") $builder .= "VALUES $this->Values";
if($this->Duplicate) $builder .= "DUPLICATE";
if($this->Replace) $builder .= "REPLACE";
return $builder;
}
public function RelativePath(string $relativePath): InsertQuery
{
self::ValidateDeegraphPath(target: $relativePath);
$this->RelativePath = $relativePath;
return $this;
}
public function Keys(string $keys): InsertQuery
{
$this->Keys = $keys;
return $this;
}
public function Schemas(string $schemas): InsertQuery
{
$this->Schemas = $schemas;
return $this;
}
public function Values(string $values): InsertQuery
{
$this->Values .= $values;
return $this;
}
public function Duplicate(): InsertQuery
{
$this->Duplicate = true;
return $this;
}
public function Replace(): InsertQuery
{
$this->Replace = true;
return $this;
}
}

81
src/QueryBuilder/QueryBuilders/InsertQueryBuilder.php

@ -0,0 +1,81 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField;
use Darksparrow\DeegraphInteractions\Interfaces\QueryBuilderInterface;
use Darksparrow\DeegraphInteractions\QueryInstance\InsertQuery;
use Darksparrow\DeegraphInteractions\Traits\QueryBuilderTrait;
#[QueryBuilderQuery]
final class InsertQueryBuilder implements QueryBuilderInterface
{
use QueryBuilderTrait;
#[QueryBuilderRequiredField]
protected string $RelativePath = "";
protected array $Keys = [];
protected array $Schemas = [];
protected string $Values = "";
protected bool $Duplicate = false;
protected bool $Replace = false;
public function Build(): InsertQuery
{
self::ValidateValues($this);
$builder = "INSERT INTO $this->RelativePath";
if(sizeof($this->Keys) > 0) $builder .= "KEYS " . implode(separator: ", ", array: $this->Keys);
if(sizeof($this->Schemas) > 0) $builder .= "SCHEMAS " . implode(separator: ", ", array: $this->Schemas);
if($this->Values != "") $builder .= "VALUES " . $this->Values;
if($this->Duplicate) $builder .= "DUPLICATE";
if($this->Replace) $builder .= "REPLACE";
return new InsertQuery($builder);
}
public function RelativePath(string $relativePath): InsertQueryBuilder
{
self::ValidateDeegraphPath(target: $relativePath);
$this->RelativePath = $relativePath;
return $this;
}
public function Keys(string $keys): InsertQueryBuilder
{
$this->Keys = $keys;
return $this;
}
public function Schemas(string $schemas): InsertQueryBuilder
{
$this->Schemas = $schemas;
return $this;
}
public function Values(string $values): InsertQueryBuilder
{
$this->Values .= $values;
return $this;
}
public function Duplicate(): InsertQueryBuilder
{
$this->Duplicate = true;
return $this;
}
public function Replace(): InsertQueryBuilder
{
$this->Replace = true;
return $this;
}
}

113
src/QueryBuilder/QueryBuilders/PutQuery.php

@ -1,113 +0,0 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders;
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderConflictingFieldAlreadyExistsException;
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderInvalidInputException;
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderRequiredFieldIsNotSetException;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait;
final class PutQuery
{
use QueryBuilderTrait;
protected string $PutWhat = "";
protected string $PutAt = "";
protected string $PutInto = "";
protected bool $Safe = false;
public function __construct()
{
}
/**
* @throws QueryBuilderRequiredFieldIsNotSetException
*/
public function __toString(): string
{
$builder = "PUT";
if($this->PutWhat != "") $builder .= " $this->PutWhat";
if($this->PutAt != "") $builder .= " $this->PutAt";
elseif ($this->PutInto != "") $builder .= " $this->PutInto";
else throw new QueryBuilderRequiredFieldIsNotSetException();
if($this->Safe) $builder .= " SAFE";
return $builder;
}
/**
* @throws QueryBuilderInvalidInputException
*/
public function Schema(string $uri): PutQuery
{
$this->PutWhat = self::RegexValidate(
target: "SCHEMA \"$uri\"",
pattern: "/SCHEMA \".+\"/"
);
return $this;
}
/**
* @throws QueryBuilderInvalidInputException
*/
public function URI(string $uri): PutQuery
{
$this->PutWhat = self::RegexValidate(
target: "URI \"$uri\"",
pattern: "/URI \".+\"/"
);
return $this;
}
/**
* @throws QueryBuilderInvalidInputException
*/
public function DataURI(string $mimeType, string $data): PutQuery
{
$this->PutWhat = self::RegexValidate(
target: "URI \"data:$mimeType;$data\"",
pattern: "/URI \"data:[a-zA-Z0-9]/[a-zA-Z0-9];.+\"/"
);
return $this;
}
/**
* @throws QueryBuilderInvalidInputException
* @throws QueryBuilderConflictingFieldAlreadyExistsException
*/
public function At(string $node, string $uwu): PutQuery
{
self::EnsureNotSet($this->PutInto);
$this->PutAt = self::RegexValidate(
target: 'AT {' . $node . '}/' . $uwu,
pattern: "/AT {[a-zA-Z0-9\-]+}\/[a-zA-Z0-9]+/"
);
return $this;
}
/**
* @throws QueryBuilderInvalidInputException
* @throws QueryBuilderConflictingFieldAlreadyExistsException
*/
public function Into(string $relativePath, string $propertyName): PutQuery
{
self::EnsureNotSet($this->PutAt);
$this->PutInto = self::RegexValidate(
target: "INTO \"$relativePath\" AS \"$propertyName\"",
pattern: "/INTO \"[a-zA-Z0-9\-]+\" AS \"[a-zA-Z0-9]+\"/"
);
return $this;
}
public function Safe(): PutQuery
{
$this->Safe = true;
return $this;
}
}

117
src/QueryBuilder/QueryBuilders/PutQueryBuilder.php

@ -0,0 +1,117 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders;
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderConflictingFieldAlreadyExistsException;
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderInvalidInputException;
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderRequiredFieldIsNotSetException;
use Darksparrow\DeegraphInteractions\Interfaces\QueryBuilderInterface;
use Darksparrow\DeegraphInteractions\QueryInstance\PutQuery;
use Darksparrow\DeegraphInteractions\Traits\QueryBuilderTrait;
final class PutQueryBuilder implements QueryBuilderInterface
{
use QueryBuilderTrait;
protected string $PutWhat = "";
protected string $PutData = "";
protected string $PutAt = "";
protected string $PutInto = "";
protected bool $Safe = false;
/**
* @throws QueryBuilderRequiredFieldIsNotSetException
*/
public function Build(): PutQuery
{
self::ValidateValues($this);
$builder = "PUT $this->PutWhat";
if($this->PutData != "") $builder .= " \"$this->PutData\" ";
if($this->PutAt != "") $builder .= "AT " . $this->PutAt;
elseif($this->PutInto != "") $builder .= "INTO " . $this->PutInto;
else throw new QueryBuilderRequiredFieldIsNotSetException();
if($this->Safe) $builder .= " SAFE";
return new PutQuery($builder);
}
/**
* @throws QueryBuilderInvalidInputException
*/
public function Schema(string $schema): PutQueryBuilder
{
$this->PutWhat = "SCHEMA";
$this->PutData = self::RegexValidate(
target: $schema,
pattern: "/.+/",
);
return $this;
}
/**
* @throws QueryBuilderInvalidInputException
*/
public function URI(string $uri): PutQueryBuilder
{
$this->PutWhat = "URI";
$this->PutData = self::RegexValidate(
target: $uri,
pattern: "/.+/",
);
return $this;
}
/**
* @throws QueryBuilderInvalidInputException
*/
public function DataURI(string $mimeType, string $data): PutQueryBuilder
{
$this->PutWhat = "URI";
$this->PutData = self::RegexValidate(
target: "data:$mimeType;$data",
pattern: "data:[a-zA-Z0-9]/[a-zA-Z0-9];.+/",
);
return $this;
}
/**
* @throws QueryBuilderInvalidInputException
* @throws QueryBuilderConflictingFieldAlreadyExistsException
*/
public function At(string $relativePath): PutQueryBuilder
{
self::EnsureNotSet($this->PutInto);
self::ValidateDeegraphPath($relativePath);
$this->PutAt = self::ValidateDeegraphPath(
target: $relativePath,
);
return $this;
}
/**
* @throws QueryBuilderInvalidInputException
* @throws QueryBuilderConflictingFieldAlreadyExistsException
*/
public function Into(string $relativePath, string $propertyName): PutQueryBuilder
{
self::EnsureNotSet($this->PutAt);
$this->PutInto = self::RegexValidate(
target: "\"$relativePath\" AS \"$propertyName\"",
pattern: "/\"[a-zA-Z0-9\-]+\" AS \"[a-zA-Z0-9]+\"/",
);
return $this;
}
public function Safe(): PutQueryBuilder
{
$this->Safe = true;
return $this;
}
}

42
src/QueryBuilder/QueryBuilders/SelectQuery.php → src/QueryBuilder/QueryBuilders/SelectQueryBuilder.php

@ -6,10 +6,12 @@ use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField;
use Darksparrow\DeegraphInteractions\Enumerators\DeegraphEqualityOperator;
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderRequiredFieldIsNotSetException;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait;
use Darksparrow\DeegraphInteractions\Interfaces\QueryBuilderInterface;
use Darksparrow\DeegraphInteractions\QueryInstance\SelectQuery;
use Darksparrow\DeegraphInteractions\Traits\QueryBuilderTrait;
#[QueryBuilderQuery]
final class SelectQuery
final class SelectQueryBuilder implements QueryBuilderInterface
{
use QueryBuilderTrait;
@ -20,45 +22,53 @@ final class SelectQuery
protected string $InstanceOf = "";
public function __construct()
{
}
/**
* @throws QueryBuilderRequiredFieldIsNotSetException
*/
public function __toString(): string
{
return $this->Build();
}
public function Build(): SelectQuery
{
self::ValidateValues($this);
$builder = "SELECT ";
if(sizeof($this->RelativePaths)) $builder .= " " . implode(separator: ", ", array: $this->RelativePaths);
if($this->From != "") $builder .= " FROM $this->From";
if($this->Where != "") $builder .= " WHERE $this->Where";
if($this->InstanceOf != "") $builder .= " INSTANCEOF $this->InstanceOf";
if(sizeof($this->RelativePaths)) $builder .= " " . implode(separator: ", ", array: $this->RelativePaths);
if($this->From != "") $builder .= " FROM " . $this->From;
if($this->Where != "") $builder .= " WHERE " . $this->Where;
if($this->InstanceOf != "") $builder .= " INSTANCEOF " . $this->InstanceOf;
return $builder;
return new SelectQuery(queryString: $builder);
}
public function RelativePath(string $relativePath): SelectQuery
public function RelativePath(string $relativePath): SelectQueryBuilder
{
$this->RelativePaths = [$relativePath];
return $this;
}
public function RelativePaths(array $relativePaths): SelectQuery
public function RelativePaths(array $relativePaths): SelectQueryBuilder
{
$this->RelativePaths = $relativePaths;
return $this;
}
public function From(string $target): SelectQuery
public function From(string $target): SelectQueryBuilder
{
$this->From = "" . $target;
return $this;
}
public function Where(string $target, DeegraphEqualityOperator $operator, string $value): SelectQuery
public function Where(string $target, DeegraphEqualityOperator $operator, string $value): SelectQueryBuilder
{
$this->Where = "" . $target . " " . $operator->value . " " . $value;
return $this;
}
public function InstanceOf(string $schema): SelectQuery
public function InstanceOf(string $schema): SelectQueryBuilder
{
$this->InstanceOf = "" . $schema;
return $this;

23
src/QueryInstance/DeleteQuery.php

@ -0,0 +1,23 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryInstance;
use Darksparrow\DeegraphInteractions\Core\DeegraphServer;
use Darksparrow\DeegraphInteractions\Enumerators\HTTPMethod;
use Darksparrow\DeegraphInteractions\Interfaces\QueryInstanceInterface;
use Darksparrow\DeegraphInteractions\QueryResponse\DeleteQueryResponse;
use Darksparrow\DeegraphInteractions\QueryResponse\GrantQueryResponse;
use Darksparrow\DeegraphInteractions\Superclasses\QueryInstanceSuperclass;
final class DeleteQuery extends QueryInstanceSuperclass implements QueryInstanceInterface
{
public function RunQuery(DeegraphServer $deegraphServer): DeleteQueryResponse
{
$response = $deegraphServer->RunRawRequest(
endpoint: "/api/v1/@delete",
method: HTTPMethod::DELETE,
body: $this->QueryString,
);
return new DeleteQueryResponse(response: $response);
}
}

22
src/QueryInstance/GrantQuery.php

@ -0,0 +1,22 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryInstance;
use Darksparrow\DeegraphInteractions\Core\DeegraphServer;
use Darksparrow\DeegraphInteractions\Enumerators\HTTPMethod;
use Darksparrow\DeegraphInteractions\Interfaces\QueryInstanceInterface;
use Darksparrow\DeegraphInteractions\QueryResponse\GrantQueryResponse;
use Darksparrow\DeegraphInteractions\Superclasses\QueryInstanceSuperclass;
final class GrantQuery extends QueryInstanceSuperclass implements QueryInstanceInterface
{
public function RunQuery(DeegraphServer $deegraphServer): GrantQueryResponse
{
$response = $deegraphServer->RunRawRequest(
endpoint: "/api/v1/@query",
method: HTTPMethod::POST,
body: $this->QueryString,
);
return new GrantQueryResponse(response: $response);
}
}

22
src/QueryInstance/InsertQuery.php

@ -0,0 +1,22 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryInstance;
use Darksparrow\DeegraphInteractions\Core\DeegraphServer;
use Darksparrow\DeegraphInteractions\Enumerators\HTTPMethod;
use Darksparrow\DeegraphInteractions\Interfaces\QueryInstanceInterface;
use Darksparrow\DeegraphInteractions\QueryResponse\InsertQueryResponse;
use Darksparrow\DeegraphInteractions\Superclasses\QueryInstanceSuperclass;
final class InsertQuery extends QueryInstanceSuperclass implements QueryInstanceInterface
{
public function RunQuery(DeegraphServer $deegraphServer): InsertQueryResponse
{
$response = $deegraphServer->RunRawRequest(
endpoint: "/api/v1/@query",
method: HTTPMethod::POST,
body: $this->QueryString,
);
return new InsertQueryResponse(response: $response);
}
}

22
src/QueryInstance/PutQuery.php

@ -0,0 +1,22 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryInstance;
use Darksparrow\DeegraphInteractions\Core\DeegraphServer;
use Darksparrow\DeegraphInteractions\Enumerators\HTTPMethod;
use Darksparrow\DeegraphInteractions\Interfaces\QueryInstanceInterface;
use Darksparrow\DeegraphInteractions\QueryResponse\PutQueryResponse;
use Darksparrow\DeegraphInteractions\Superclasses\QueryInstanceSuperclass;
final class PutQuery extends QueryInstanceSuperclass implements QueryInstanceInterface
{
public function RunQuery(DeegraphServer $deegraphServer): PutQueryResponse
{
$response = $deegraphServer->RunRawRequest(
endpoint: "/api/v1/@query",
method: HTTPMethod::POST,
body: $this->QueryString,
);
return new PutQueryResponse(response: $response);
}
}

22
src/QueryInstance/SelectQuery.php

@ -0,0 +1,22 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryInstance;
use Darksparrow\DeegraphInteractions\Core\DeegraphServer;
use Darksparrow\DeegraphInteractions\Enumerators\HTTPMethod;
use Darksparrow\DeegraphInteractions\Interfaces\QueryInstanceInterface;
use Darksparrow\DeegraphInteractions\QueryResponse\SelectQueryResponse;
use Darksparrow\DeegraphInteractions\Superclasses\QueryInstanceSuperclass;
final class SelectQuery extends QueryInstanceSuperclass implements QueryInstanceInterface
{
public function RunQuery(DeegraphServer $deegraphServer): SelectQueryResponse
{
$response = $deegraphServer->RunRawRequest(
endpoint: "/api/v1/@query",
method: HTTPMethod::POST,
body: $this->QueryString,
);
return new SelectQueryResponse(response: $response);
}
}

13
src/QueryResponse/DeleteQueryResponse.php

@ -0,0 +1,13 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryResponse;
use Darksparrow\DeegraphInteractions\Interfaces\QueryResponseInterface;
final class DeleteQueryResponse implements QueryResponseInterface
{
public function __construct(string $response)
{
$response = json_decode($response, true);
}
}

17
src/QueryResponse/GrantQueryResponse.php

@ -0,0 +1,17 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryResponse;
use Darksparrow\DeegraphInteractions\Interfaces\QueryResponseInterface;
final class GrantQueryResponse implements QueryResponseInterface
{
protected string $RuleID;
public function __construct(string $response)
{
$response = json_decode($response, true);
$this->RuleID = $response["@rule_id"];
}
}

13
src/QueryResponse/InsertQueryResponse.php

@ -0,0 +1,13 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryResponse;
use Darksparrow\DeegraphInteractions\Interfaces\QueryResponseInterface;
final class InsertQueryResponse implements QueryResponseInterface
{
public function __construct(string $response)
{
$response = json_decode($response, true);
}
}

14
src/QueryResponse/PutQueryResponse.php

@ -0,0 +1,14 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryResponse;
use Darksparrow\DeegraphInteractions\Interfaces\QueryResponseInterface;
final class PutQueryResponse implements QueryResponseInterface
{
public function __construct(string $response)
{
$response = json_decode($response, true);
}
}

44
src/QueryResponse/SelectQueryResponse.php

@ -0,0 +1,44 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryResponse;
use Darksparrow\DeegraphInteractions\DataStructures\QueryResponseRow;
use Darksparrow\DeegraphInteractions\Interfaces\QueryResponseInterface;
final class SelectQueryResponse implements QueryResponseInterface
{
public array $Rows;
public string $RowFormat;
public function __construct(string $response)
{
$response = json_decode($response, true);
echo "\n\n\n";
var_dump($response);
echo "\n\n\n";
if(array_key_exists(key: "@rows", array: $response))
{
$this->Rows = [];
foreach($response["@rows"] as $row)
$this->Rows[] = new QueryResponseRow(array: $row);
$this->RowFormat = $response["@row_format"];
}
}
public function FlattenRows(): array
{
$builder = [];
foreach($this->Rows as $row)
{
foreach($row->Results as $result)
{
$builder[] = $result;
}
}
return $builder;
}
}

33
src/Superclasses/QueryInstanceSuperclass.php

@ -0,0 +1,33 @@
<?php
namespace Darksparrow\DeegraphInteractions\Superclasses;
class QueryInstanceSuperclass
{
protected string $QueryString;
/**
* Build a new Query Instance from a Query String.
*
* @param string $queryString
*/
public function __construct(string $queryString)
{
$this->QueryString = $queryString;
}
/**
* Returns back the Query Instance as a string object.
*
* @return string
*/
public function __toString(): string
{
return $this->AsString();
}
public function AsString(): string
{
return $this->QueryString;
}
}

86
src/Traits/QueryBuilderTrait.php

@ -0,0 +1,86 @@
<?php
namespace Darksparrow\DeegraphInteractions\Traits;
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderConflictingFieldAlreadyExistsException;
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderInvalidInputException;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\DeleteQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\GrantQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\InsertQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\PutQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders\SelectQueryBuilder;
use Exception;
use ReflectionClass;
trait QueryBuilderTrait
{
/**
* Takes in a string and a pattern.
* If the string matches the pattern, it'll return the given string, if it doesn't, it'll throw an exception.
*
* @param string $target
* @param string $pattern
*
* @return string
*
* @throws QueryBuilderInvalidInputException
*/
protected function RegexValidate(string $target, string $pattern): string
{
if(!preg_match(pattern: $pattern, subject: $target))
throw new QueryBuilderInvalidInputException();
return $target;
}
/**
* Ensures that the provided string is equal to empty string (""))
*
* @param string $target
*
* @return void
* @throws QueryBuilderConflictingFieldAlreadyExistsException
*/
protected function EnsureNotSet(string $target): void
{
if($target != "")
throw new QueryBuilderConflictingFieldAlreadyExistsException();
}
protected function ValidateDeegraphPath(string $target): string
{
if(!preg_match(pattern: "/(^(\{[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}\})$)|(^\{[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}\}(\/([a-z][a-z0-9]*|[0-9]+|#|\*))+$)|(^(([a-z][a-z0-9]*|[0-9]+|#|\*))(\/([a-z][a-z0-9]*|[0-9]+|#|\*))*$)/", subject: $target))
throw new QueryBuilderInvalidInputException();
return $target;
}
public function ValidateValues(
DeleteQueryBuilder
|GrantQueryBuilder
|InsertQueryBuilder
|PutQueryBuilder
|SelectQueryBuilder $target
): void
{
$nameBase = "Darksparrow\\DeegraphPHP\\Attributes";
$reflection = new ReflectionClass($target);
$properties = $reflection->getProperties();
foreach($properties as $property)
{
$attributes = $property->getAttributes();
$propertyName = $property->getName();
$propertyValue = $property->getValue($target);
if(sizeof($attributes) == 0) continue;
foreach($attributes as $attribute)
{
if($attribute->getName() == "$nameBase\\QueryBuilderRequiredField")
{
if($propertyValue == "")
throw new Exception();
}
}
}
}
}

13
tests/QueryBuilderPutTest.php

@ -9,23 +9,22 @@ final class QueryBuilderPutTest extends TestCase
{
public function testPutURIAtSafeWithValidData()
{
$queryBuilder = new QueryBuilder();
$query = $queryBuilder->Put()
$query = QueryBuilder::Put()
->URI("https://schemas.auxiliumsoftware.co.uk/v1/collection.json")
->At(node: "970334ed-1f4f-465a-94d7-923a99698786", uwu: "todos")
->At(relativePath: "{970334ed-1f4f-465a-94d7-923a99698786}/todos")
->Safe();
self::assertEquals(
expected: 'PUT URI "https://schemas.auxiliumsoftware.co.uk/v1/collection.json" AT {970334ed-1f4f-465a-94d7-923a99698786}/todos SAFE',
actual: $query
actual: $query->Build()->AsString(),
);
}
public function testPutWithBothThings()
{
$this->expectException(QueryBuilderConflictingFieldAlreadyExistsException::class);
$queryBuilder = new QueryBuilder();
$query = $queryBuilder->Put()
$query = QueryBuilder::Put()
->URI("https://schemas.auxiliumsoftware.co.uk/v1/collection.json")
->At(node: "970334ed-1f4f-465a-94d7-923a99698786", uwu: "todos")
->At(relativePath: "{970334ed-1f4f-465a-94d7-923a99698786}/todos")
->Into(relativePath: "Relative Path", propertyName: "OwO")
->Safe();
}

Loading…
Cancel
Save