PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Settings.php

Settings.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Settings.php

170 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet;
4
5 use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Calculation;
6 use TablePress\PhpOffice\PhpSpreadsheet\Chart\Renderer\IRenderer;
7 use TablePress\PhpOffice\PhpSpreadsheet\Collection\Memory;
8 use TablePress\Psr\SimpleCache\CacheInterface;
9 use ReflectionClass;
10
11 class Settings
12 {
13 /**
14 * Class name of the chart renderer used for rendering charts
15 * eg: TablePress\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph.
16 *
17 * @var null|class-string<IRenderer>
18 */
19 private static ?string $chartRenderer = null;
20
21 /**
22 * The cache implementation to be used for cell collection.
23 */
24 private static ?CacheInterface $cache = null;
25
26 /**
27 * @var mixed
28 */
29 private static $httpClient = null;
30
31 /**
32 * @var mixed
33 */
34 private static $requestFactory = null;
35
36 /**
37 * Set the locale code to use for formula translations and any special formatting.
38 *
39 * @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk")
40 *
41 * @return bool Success or failure
42 */
43 public static function setLocale(string $locale): bool
44 {
45 return Calculation::getInstance()->setLocale($locale);
46 }
47
48 public static function getLocale(): string
49 {
50 return Calculation::getInstance()->getLocale();
51 }
52
53 /**
54 * Identify to PhpSpreadsheet the external library to use for rendering charts.
55 *
56 * @param class-string<IRenderer> $rendererClassName Class name of the chart renderer
57 * eg: TablePress\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph
58 */
59 public static function setChartRenderer(string $rendererClassName): void
60 {
61 if (!is_a($rendererClassName, IRenderer::class, true)) {
62 throw new Exception('Chart renderer must implement ' . IRenderer::class);
63 }
64
65 self::$chartRenderer = $rendererClassName;
66 }
67
68 public static function unsetChartRenderer(): void
69 {
70 self::$chartRenderer = null;
71 }
72
73 /**
74 * Return the Chart Rendering Library that PhpSpreadsheet is currently configured to use.
75 *
76 * @return null|class-string<IRenderer> Class name of the chart renderer
77 * eg: TablePress\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph
78 */
79 public static function getChartRenderer(): ?string
80 {
81 return self::$chartRenderer;
82 }
83
84 public static function htmlEntityFlags(): int
85 {
86 return ENT_COMPAT;
87 }
88
89 /**
90 * Sets the implementation of cache that should be used for cell collection.
91 */
92 public static function setCache(?CacheInterface $cache): void
93 {
94 self::$cache = $cache;
95 }
96
97 /**
98 * Gets the implementation of cache that is being used for cell collection.
99 */
100 public static function getCache(): CacheInterface
101 {
102 if (!self::$cache) {
103 self::$cache = self::useSimpleCacheVersion3() ? new Memory\SimpleCache3() : new Memory\SimpleCache1();
104 }
105
106 return self::$cache;
107 }
108
109 public static function useSimpleCacheVersion3(): bool
110 {
111 return
112 PHP_MAJOR_VERSION === 8 &&
113 (new ReflectionClass(CacheInterface::class))->getMethod('get')->getReturnType() !== null;
114 }
115
116 /**
117 * Set the HTTP client implementation to be used for network request.
118 *
119 * @deprecated 5.4.0 No replacement.
120 *
121 * @codeCoverageIgnore
122 * @param mixed $httpClient
123 * @param mixed $requestFactory
124 */
125 public static function setHttpClient($httpClient, $requestFactory): void
126 {
127 self::$httpClient = $httpClient;
128 self::$requestFactory = $requestFactory;
129 }
130
131 /**
132 * Unset the HTTP client configuration.
133 *
134 * @deprecated 5.4.0 No replacement.
135 *
136 * @codeCoverageIgnore
137 */
138 public static function unsetHttpClient(): void
139 {
140 self::$httpClient = null;
141 self::$requestFactory = null;
142 }
143
144 /**
145 * Get the HTTP client implementation to be used for network request.
146 *
147 * @deprecated 5.4.0 No replacement.
148 *
149 * @codeCoverageIgnore
150 * @return mixed
151 */
152 public static function getHttpClient()
153 {
154 return self::$httpClient;
155 }
156
157 /**
158 * Get the HTTP request factory.
159 *
160 * @deprecated 5.4.0 No replacement.
161 *
162 * @codeCoverageIgnore
163 * @return mixed
164 */
165 public static function getRequestFactory()
166 {
167 return self::$requestFactory;
168 }
169 }
170