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 / Style / NumberFormat / Wizard / Scientific.php

Scientific.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Style/NumberFormat/Wizard/Scientific.php

34 lines 1.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\Style\NumberFormat\Wizard;
4
5 use TablePress\PhpOffice\PhpSpreadsheet\Exception;
6
7 class Scientific extends NumberBase implements Wizard
8 {
9 /**
10 * @param int $decimals number of decimal places to display, in the range 0-30
11 * @param ?string $locale Set the locale for the scientific format; or leave as the default null.
12 * Locale has no effect for Scientific Format values, and is retained here for compatibility
13 * with the other Wizards.
14 * If provided, Locale values must be a valid formatted locale string (e.g. 'en-GB', 'fr', uz-Arab-AF).
15 *
16 * @throws Exception If a provided locale code is not a valid format
17 */
18 public function __construct(int $decimals = 2, ?string $locale = null)
19 {
20 $this->setDecimals($decimals);
21 $this->setLocale($locale);
22 }
23
24 protected function getLocaleFormat(): string
25 {
26 return $this->format();
27 }
28
29 public function format(): string
30 {
31 return sprintf('0%sE+00', $this->decimals > 0 ? '.' . str_repeat('0', $this->decimals) : null);
32 }
33 }
34