at path:
ROOT
/
wp-content
/
plugins
/
woocommerce
/
src
/
StoreApi
/
Formatters.php
run:
R
W
Run
Exceptions
DIR
2026-04-15 05:42:47
R
W
Run
Formatters
DIR
2026-04-15 05:42:47
R
W
Run
Payments
DIR
2026-04-15 05:42:47
R
W
Run
Routes
DIR
2026-04-15 05:42:47
R
W
Run
Schemas
DIR
2026-04-15 05:42:47
R
W
Run
Utilities
DIR
2026-04-15 05:42:47
R
W
Run
Authentication.php
13.86 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
Formatters.php
1.21 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
Legacy.php
3.09 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
RoutesController.php
6.77 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
SchemaController.php
3.34 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
SessionHandler.php
4.81 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
StoreApi.php
3.52 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
deprecated.php
7.97 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
functions.php
2.7 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
error_log
up
📄
Formatters.php
Save
<?php namespace Automattic\WooCommerce\StoreApi; use \Exception; use Automattic\WooCommerce\StoreApi\Formatters\DefaultFormatter; /** * Formatters class. * * Allows formatter classes to be registered. Formatters are exposed to extensions via the ExtendSchema class. */ class Formatters { /** * Holds an array of formatter class instances. * * @var array */ private $formatters = []; /** * Get a new instance of a formatter class. * * @throws Exception An Exception is thrown if a non-existing formatter is used and the user is admin. * * @param string $name Name of the formatter. * @return FormatterInterface Formatter class instance. */ public function __get( $name ) { if ( ! isset( $this->formatters[ $name ] ) ) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && current_user_can( 'manage_woocommerce' ) ) { throw new Exception( $name . ' formatter does not exist' ); } return new DefaultFormatter(); } return $this->formatters[ $name ]; } /** * Register a formatter class for usage. * * @param string $name Name of the formatter. * @param string $class A formatter class name. */ public function register( $name, $class ) { $this->formatters[ $name ] = new $class(); } }