PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.8
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.8
1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 0.8.6 All 33 releases
desktop-mode / includes / framework / app / standalone / class-env.php

class-env.php in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 1.1.8, at includes/framework/app/standalone/class-env.php

78 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * OpenStation App Framework — standalone Env adapter.
4 *
5 * Answers from PHP itself: real `define()`d constants, a content
6 * directory the host passes in, the PHP version as the platform.
7 *
8 * @package OpenStation
9 */
10
11 namespace OpenStation\App\Standalone;
12
13 use OpenStation\App\Contracts\Env as EnvContract;
14
15 // Direct access, unless a standalone host is booting on bare PHP.
16 if ( ! defined( 'ABSPATH' ) ) {
17 defined( 'OPENSTATION_STANDALONE' ) || exit;
18 }
19
20 /**
21 * Plain-PHP environment facts.
22 */
23 final class Env implements EnvContract {
24
25 /**
26 * @var string
27 */
28 private $content_dir;
29
30 /**
31 * @var string
32 */
33 private $environment_type;
34
35 /**
36 * @param string $content_dir Writable content directory. Defaults to the system temp dir.
37 * @param string $environment_type `production` | `staging` | `development` | `local`.
38 */
39 public function __construct( $content_dir = '', $environment_type = 'production' ) {
40 $this->content_dir = '' !== $content_dir ? rtrim( (string) $content_dir, '/\\' ) : sys_get_temp_dir();
41 $this->environment_type = (string) $environment_type;
42 }
43
44 /** {@inheritDoc} */
45 public function constant( $name, $fallback = null ) {
46 return defined( $name ) ? constant( $name ) : $fallback;
47 }
48
49 /** {@inheritDoc} */
50 public function content_dir() {
51 return $this->content_dir;
52 }
53
54 /** {@inheritDoc} */
55 public function platform() {
56 return array(
57 'name' => 'PHP',
58 'version' => PHP_VERSION,
59 );
60 }
61
62 /** {@inheritDoc} */
63 public function environment_type() {
64 return $this->environment_type;
65 }
66
67 /** {@inheritDoc} */
68 public function is_network() {
69 return false;
70 }
71
72 /** {@inheritDoc} */
73 public function format_datetime( $timestamp, $format = 'Y-m-d H:i:s' ) {
74 // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date -- The standalone host has no site timezone; PHP's own is the contract here.
75 return date( (string) $format, (int) $timestamp );
76 }
77 }
78