summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/jetpack_vendor/automattic/jetpack-status/src/class-files.php')
-rw-r--r--plugins/jetpack/jetpack_vendor/automattic/jetpack-status/src/class-files.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/plugins/jetpack/jetpack_vendor/automattic/jetpack-status/src/class-files.php b/plugins/jetpack/jetpack_vendor/automattic/jetpack-status/src/class-files.php
new file mode 100644
index 00000000..5f5e4129
--- /dev/null
+++ b/plugins/jetpack/jetpack_vendor/automattic/jetpack-status/src/class-files.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * A modules class for Jetpack.
+ *
+ * @package automattic/jetpack-status
+ */
+
+namespace Automattic\Jetpack;
+
+/**
+ * Class Automattic\Jetpack\Files
+ *
+ * Used to retrieve information about files.
+ */
+class Files {
+ /**
+ * Returns an array of all PHP files in the specified absolute path.
+ * Equivalent to glob( "$absolute_path/*.php" ).
+ *
+ * @param string $absolute_path The absolute path of the directory to search.
+ * @return array Array of absolute paths to the PHP files.
+ */
+ public function glob_php( $absolute_path ) {
+ if ( function_exists( 'glob' ) ) {
+ return glob( "$absolute_path/*.php" );
+ }
+
+ $absolute_path = untrailingslashit( $absolute_path );
+ $files = array();
+ $dir = @opendir( $absolute_path ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
+ if ( ! $dir ) {
+ return $files;
+ }
+
+ // phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
+ while ( false !== $file = readdir( $dir ) ) {
+ if ( '.' === substr( $file, 0, 1 ) || '.php' !== substr( $file, -4 ) ) {
+ continue;
+ }
+
+ $file = "$absolute_path/$file";
+
+ if ( ! is_file( $file ) ) {
+ continue;
+ }
+
+ $files[] = $file;
+ }
+
+ closedir( $dir );
+
+ return $files;
+ }
+}