Completed
Push — use-asset-tools-package-everyw... ( f15c55...95b21d )
by
unknown
28:56 queued 20:20
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
3
namespace Automattic\Jetpack;
4
5
use Automattic\Jetpack\Constants as Jetpack_Constants;
6
7
class Assets {
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
	/**
29
	 * Use only when we can't instantiate a client object with
30
	 * this as a constructor argument because we can't modify the call
31
	 * to the constructor.
32
	 *
33
	 * @return Assets
34
	 */
35
	public static function get_instance() {
36
		return new Assets();
37
	}
38
}
39