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

PHP-Alchemist / coreFiles / 13531756279

25 Feb 2025 09:58PM UTC coverage: 96.481% (+0.006%) from 96.475%
13531756279

push

github

druid628
Uses coverallsapp/github-actions@v2

521 of 540 relevant lines covered (96.48%)

4.99 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
     * @param        $row
12
     * @param string $delimiter
13
     * @param string $enclosure
14
     * @param string $eol
15
     *
16
     * @return bool|string
17
     */
18
    public static function sputcsv($row, $delimiter = ',', $enclosure = '"', $eol = PHP_EOL)
2✔
19
    {
20
        static $fp = false;
2✔
21
        if ($fp === false) {
2✔
22
            $fp = fopen('php://temp', 'r+'); // see http://php.net/manual/en/wrappers.php.php - yes there are 2 '.php's on the end.
1✔
23
        // NB: anything you read/write to/from 'php://temp' is specific to this filehandle
24
        } else {
25
            rewind($fp);
2✔
26
        }
27

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

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

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

39
        return $csv;
2✔
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