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

PHP-Alchemist / coreFiles / 15422917341

03 Jun 2025 04:38PM UTC coverage: 92.356%. First build
15422917341

Pull #9

github

druid628
minimizes AbstractAssociativeArray to reduce duplication still have AbstractIndexed, AbstractKeyValuePair, and AbstractList to go
Pull Request #9: [Release] v3.0.0

134 of 167 new or added lines in 16 files covered. (80.24%)

592 of 641 relevant lines covered (92.36%)

4.53 hits per line

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

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

3
namespace PHPAlchemist\Utility;
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

© 2025 Coveralls, Inc