• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PHPOffice / PhpSpreadsheet / 28774268733

06 Jul 2026 07:10AM UTC coverage: 97.157% (-0.01%) from 97.167%
28774268733

Pull #4834

github

web-flow
Merge 22dd8078e into 0577c7488
Pull Request #4834: Add parallel Xlsx writing via pcntl_fork

189 of 200 new or added lines in 6 files covered. (94.5%)

48553 of 49974 relevant lines covered (97.16%)

385.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/src/PhpSpreadsheet/Parallel/CpuDetector.php
1
<?php
2

3
namespace PhpOffice\PhpSpreadsheet\Parallel;
4

5
use Fidry\CpuCoreCounter\CpuCoreCounter;
6
use Fidry\CpuCoreCounter\NumberOfCpuCoreNotFound;
7

8
class CpuDetector
9
{
10
    private const FALLBACK_CPU_COUNT = 2;
11

12
    private static ?int $cachedCount = null;
13

14
    public static function detectCpuCount(): int
9✔
15
    {
16
        if (self::$cachedCount !== null) {
9✔
17
            return self::$cachedCount;
6✔
18
        }
19

20
        self::$cachedCount = static::detect();
4✔
21

22
        return self::$cachedCount;
4✔
23
    }
24

25
    /**
26
     * Reset cached value (for testing).
27
     */
28
    public static function reset(): void
3✔
29
    {
30
        self::$cachedCount = null;
3✔
31
    }
32

33
    protected static function detect(): int
4✔
34
    {
35
        try {
36
            return (new CpuCoreCounter())->getCount();
4✔
NEW
37
        } catch (NumberOfCpuCoreNotFound) {
×
38
            return self::FALLBACK_CPU_COUNT; // @codeCoverageIgnore
39
        }
40
    }
41
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc