Skip to content

Commit

Permalink
WIP: XML API: Introduce XML Processor.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed Aug 26, 2024
1 parent 15dca4e commit a7fe382
Show file tree
Hide file tree
Showing 3 changed files with 467 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/wp-includes/xml-api/class-wp-xml-malformed-error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

class WP_XML_Malformed_Error extends ValueError {
public $level_of_concern;

public function __construct( int $level_of_concern, string $message ) {
parent::__construct( $message );
$this->level_of_concern = $level_of_concern;
}

public function get_level_of_concern(): int {
switch ( $this->level_of_concern ) {
case WP_XML_Processor::CONCERNED_ABOUT_EVERYTHING:
return 'EVERYTHING';

case WP_XML_Processor::CONCERNED_ABOUT_CONTENT:
return 'CONTENT';

case WP_XML_Processor::CONCERNED_ABOUT_BENIGN_SYNTAX:
return 'BENIGN_SYNTAX';

case WP_XML_Processor::CONCERNED_ABOUT_INVALID_SYNTAX:
return 'INVALID_SYNTAX';

case WP_XML_Processor::CONCERNED_ABOUT_UNRESOLVABLES:
return 'UNRESOLVABLE';

default:
throw new ValueError( "Unknown level of concern: {$this->level_of_concern}" );
}
}
}
Loading

0 comments on commit a7fe382

Please sign in to comment.