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

voku / Stringy / 4439859016

pending completion
4439859016

Pull #40

github

GitHub
Merge 03132f915 into c453c88fb
Pull Request #40: Configure Renovate

1000 of 1024 relevant lines covered (97.66%)

69.36 hits per line

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

69.23
/src/Create.php
1
<?php
2

3
namespace Stringy;
4

5
if (!\function_exists('Stringy\create')) {
×
6
    /**
7
     * Creates a Stringy object and returns it on success.
8
     *
9
     * @param object|scalar $str      Value to modify, after being cast to string
10
     * @param string        $encoding The character encoding
11
     *
12
     * @throws \InvalidArgumentException if an array or object without a
13
     *                                   __toString method is passed as the first argument
14
     *
15
     * @return Stringy A Stringy object
16
     */
17
    function create($str, string $encoding = null)
18
    {
19
        return new Stringy($str, $encoding);
14✔
20
    }
21
}
22

23
if (!\function_exists('Stringy\collection')) {
×
24
    /**
25
     * @param string[]|Stringy[]|null $input
26
     *
27
     * @throws \TypeError
28
     *
29
     * @return CollectionStringy<int,Stringy>
30
     */
31
    function collection($input = null)
32
    {
33
        // init
34
        $newCollection = new CollectionStringy();
1✔
35

36
        if ($input === null) {
1✔
37
            return $newCollection;
×
38
        }
39

40
        /**
41
         * @psalm-suppress DocblockTypeContradiction
42
         */
43
        if (!\is_array($input)) {
1✔
44
            $input = [$input];
×
45
        }
46

47
        foreach ($input as &$stringOrStringy) {
1✔
48
            if (\is_string($stringOrStringy)) {
1✔
49
                $stringOrStringy = new Stringy($stringOrStringy);
1✔
50
            }
51
            assert($stringOrStringy instanceof Stringy);
52

53
            /** @phpstan-ignore-next-line - FP? */
54
            $newCollection[] = $stringOrStringy;
1✔
55
        }
56

57
        return $newCollection;
1✔
58
    }
59
}
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