PluginProbe
DecaLog / 4.4.0
DecaLog v4.4.0
3.0.2 3.1.0 3.10.0 3.2.0 3.3.0 3.4.0 3.4.1 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.6.3 3.7.0 3.7.1 3.8.0 3.9.0 3.9.1 4.0.0 4.1.0 4.2.0 4.3.0 4.3.1 4.4.0 4.5.0 All 75 releases
decalog / includes / system / class-php.php

class-php.php in DecaLog 4.4.0, at includes/system/class-php.php

62 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PHP utilities.
4 *
5 * Helpers for PHP paths and files handling.
6 *
7 * @package System
8 * @author Pierre Lannoy <https://pierre.lannoy.fr/>.
9 * @since 2.0.0
10 */
11
12 namespace Decalog\System;
13
14 use Decalog\System\Option;
15 use Decalog\System\File;
16 use Decalog\Logger;
17
18 /**
19 * Define the PHP functionality.
20 *
21 * Helpers for PHP paths and files handling.
22 *
23 * @package System
24 * @author Pierre Lannoy <https://pierre.lannoy.fr/>.
25 * @since 2.0.0
26 */
27 class PHP {
28
29 /**
30 * Normalizes a path+file.
31 *
32 * @param string $file The raw file name.
33 * @return string The normalized file name.
34 * @since 2.0.0
35 */
36 public static function normalized_file( $file ) {
37 if ( 'unknown' === $file || '' === $file ) {
38 return 'PHP kernel';
39 }
40 if ( false !== strpos( $file, 'phar://' ) ) {
41 return str_replace( 'phar://', '', wp_normalize_path( $file ) );
42 }
43 return './' . str_replace( wp_normalize_path( ABSPATH ), '', wp_normalize_path( $file ) );
44 }
45
46 /**
47 * Normalizes a path+file.
48 *
49 * @param string $file The raw file name.
50 * @param string $line Optional. The file line.
51 * @return string The normalized file name.
52 * @since 2.0.0
53 */
54 public static function normalized_file_line( $file, $line = '' ) {
55 if ( '' === (string) $line || '0' === (string) $line ) {
56 return self::normalized_file( $file );
57 }
58 return self::normalized_file( $file ) . ':' . (string) $line;
59 }
60
61 }
62