├── composer.json ├── phpstan.neon.dist └── src ├── Xml ├── Document.php ├── Facade.php └── Reader.php └── XmlServiceProvider.php /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "orchestra/parser", 3 | "description": "XML Document Parser for Laravel and PHP", 4 | "keywords": [ 5 | "laravel", 6 | "orchestral", 7 | "orchestra-platform", 8 | "xml", 9 | "parser" 10 | ], 11 | "license": "MIT", 12 | "authors": [ 13 | { 14 | "name": "Mior Muhammad Zaki", 15 | "email": "crynobone@gmail.com", 16 | "homepage": "https://github.com/crynobone" 17 | } 18 | ], 19 | "autoload": { 20 | "psr-4": { 21 | "Orchestra\\Parser\\": "src/" 22 | } 23 | }, 24 | "autoload-dev": { 25 | "psr-4": { 26 | "Orchestra\\Parser\\Tests\\": "tests/", 27 | "Workbench\\App\\": "workbench/app/" 28 | } 29 | }, 30 | "require": { 31 | "php": "^8.2", 32 | "illuminate/container": "^12.0", 33 | "laravie/parser": "^3.0" 34 | }, 35 | "require-dev": { 36 | "laravel/pint": "^1.21", 37 | "orchestra/testbench": "^10.0", 38 | "phpstan/phpstan": "^2.0", 39 | "phpunit/phpunit": "^11.5" 40 | }, 41 | "extra": { 42 | "branch-alias": { 43 | "dev-master": "9.0-dev" 44 | }, 45 | "laravel": { 46 | "providers": [ 47 | "Orchestra\\Parser\\XmlServiceProvider" 48 | ] 49 | } 50 | }, 51 | "scripts": { 52 | "post-autoload-dump": [ 53 | "@clear", 54 | "@prepare" 55 | ], 56 | "clear": "@php vendor/bin/testbench package:purge-skeleton --ansi", 57 | "prepare": "@php vendor/bin/testbench package:discover --ansi", 58 | "build": "@php vendor/bin/testbench workbench:build --ansi", 59 | "ci": [ 60 | "@prepare", 61 | "@lint", 62 | "@test" 63 | ], 64 | "lint": [ 65 | "@php vendor/bin/pint", 66 | "@php vendor/bin/phpstan analyse" 67 | ], 68 | "test": [ 69 | "@php vendor/bin/phpunit" 70 | ] 71 | }, 72 | "config": { 73 | "sort-packages": true 74 | }, 75 | "prefer-stable": true, 76 | "minimum-stability": "dev" 77 | } 78 | -------------------------------------------------------------------------------- /phpstan.neon.dist: -------------------------------------------------------------------------------- 1 | includes: 2 | 3 | parameters: 4 | paths: 5 | - src 6 | 7 | # The level 8 is the highest level 8 | level: 8 9 | 10 | ignoreErrors: 11 | # - identifier: missingType.generics 12 | - identifier: missingType.iterableValue 13 | 14 | treatPhpDocTypesAsCertain: false 15 | -------------------------------------------------------------------------------- /src/Xml/Document.php: -------------------------------------------------------------------------------- 1 | app = $app; 23 | } 24 | 25 | /** 26 | * Make filter resolver. 27 | * 28 | * @return array{0: object, 1: string} 29 | */ 30 | #[\Override] 31 | protected function makeFilterResolver(string $class, string $method): array 32 | { 33 | return [$this->app->make($class), $method]; 34 | } 35 | 36 | /** 37 | * Call filter to parse the value. 38 | * 39 | * @param mixed $value 40 | * @return mixed 41 | */ 42 | #[\Override] 43 | protected function callFilterResolver(callable $resolver, $value) 44 | { 45 | return $this->app->call($resolver, ['value' => $value]); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Xml/Facade.php: -------------------------------------------------------------------------------- 1 | document->setContent($xml); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/XmlServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->bind('orchestra.parser.xml', static function (Container $app) { 21 | return new XmlReader(new XmlDocument($app)); 22 | }); 23 | } 24 | 25 | /** 26 | * Get the services provided by the provider. 27 | * 28 | * @return array 29 | */ 30 | public function provides() 31 | { 32 | return ['orchestra.parser.xml']; 33 | } 34 | } 35 | --------------------------------------------------------------------------------