Completed
Push — branch-7.5 ( 5f3718...c51c1e )
by Jeremy
222:03 queued 214:12
created

Assets::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
namespace Automattic\Jetpack;
3
4
use Automattic\Jetpack\Constants as Jetpack_Constants;
5
6
class Assets {
7
	// static-only class
8
	private function __construct() {}
9
10
	/**
11
	 * Given a minified path, and a non-minified path, will return
12
	 * a minified or non-minified file URL based on whether SCRIPT_DEBUG is set and truthy.
13
	 *
14
	 * Both `$min_base` and `$non_min_base` are expected to be relative to the
15
	 * root Jetpack directory.
16
	 *
17
	 * @since 5.6.0
18
	 *
19
	 * @param string $min_path
20
	 * @param string $non_min_path
21
	 * @return string The URL to the file
22
	 */
23
	public static function get_file_url_for_environment( $min_path, $non_min_path ) {
24
		$path = ( Jetpack_Constants::is_defined( 'SCRIPT_DEBUG' ) && Jetpack_Constants::get_constant( 'SCRIPT_DEBUG' ) )
25
			? $non_min_path
26
			: $min_path;
27
		return plugins_url( $path, Jetpack_Constants::get_constant( 'JETPACK__PLUGIN_FILE' ) );
28
	}
29
}
30