Completed
Push — add/clean-composer-script ( c617d2 )
by
unknown
10:30
created

Asset_Tools::get_file_url_for_environment()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 4
nop 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Automattic\Jetpack;
4
5
use Automattic\Jetpack\Constants as Jetpack_Constants;
6
7
class Asset_Tools {
8
	/**
9
	 * Given a minified path, and a non-minified path, will return
10
	 * a minified or non-minified file URL based on whether SCRIPT_DEBUG is set and truthy.
11
	 *
12
	 * Both `$min_base` and `$non_min_base` are expected to be relative to the
13
	 * root Jetpack directory.
14
	 *
15
	 * @since 5.6.0
16
	 *
17
	 * @param string $min_path
18
	 * @param string $non_min_path
19
	 * @return string The URL to the file
20
	 */
21
	public function get_file_url_for_environment( $min_path, $non_min_path ) {
22
		$path = ( Jetpack_Constants::is_defined( 'SCRIPT_DEBUG' ) && Jetpack_Constants::get_constant( 'SCRIPT_DEBUG' ) )
23
			? $non_min_path
24
			: $min_path;
25
		return plugins_url( $path, JETPACK__PLUGIN_FILE );
26
	}
27
}
28