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

PHP-Alchemist / coreFiles / 15365651291

31 May 2025 04:49PM UTC coverage: 92.598%. First build
15365651291

Pull #14

github

druid628
Updates composer lock file
Pull Request #14: v2.2.0

74 of 103 new or added lines in 9 files covered. (71.84%)

588 of 635 relevant lines covered (92.6%)

4.55 hits per line

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

91.67
/src/Utilities/CSVUtil.php
1
<?php
2

3
namespace PHPAlchemist\Utilities;
4

5
class CSVUtil
6
{
7
    /**
8
     * Nice String output replacement form fputcsv
9
     * code taken from: http://www.php.net/manual/en/function.fputcsv.php#96937.
10
     *
11
     *
12
     * @param array  $row
13
     * @param string $delimiter
14
     * @param string $enclosure
15
     * @param string $eol
16
     *
17
     * @return bool|string
18
     */
19
    public static function sputcsv(array $row, string $delimiter = ',', string $enclosure = '"', string $eol = PHP_EOL) : string
2✔
20
    {
21
        static $fp = false;
2✔
22
        if ($fp === false) {
2✔
23
            $fp = fopen('php://temp', 'r+'); // see http://php.net/manual/en/wrappers.php.php - yes there are 2 '.php's on the end.
1✔
24
            // NB: anything you read/write to/from 'php://temp' is specific to this filehandle
25
        } else {
26
            rewind($fp);
2✔
27
        }
28

29
        if (fputcsv($fp, $row, $delimiter, $enclosure, '\\', PHP_EOL) === false) {
2✔
NEW
30
            return '';
×
31
        }
32

33
        rewind($fp);
2✔
34
        $csv = fgets($fp);
2✔
35

36
        if ($eol != PHP_EOL) {
2✔
37
            $csv = substr($csv, 0, 0 - strlen(PHP_EOL)).$eol;
1✔
38
        }
39

40
        return $csv;
2✔
41
    }
42
}
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