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

nette / neon / 22293166616

23 Feb 2026 04:40AM UTC coverage: 98.488%. Remained the same
22293166616

push

github

dg
added CLAUDE.md

456 of 463 relevant lines covered (98.49%)

0.98 hits per line

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

93.75
/src/Neon/Neon.php
1
<?php declare(strict_types=1);
2

3
/**
4
 * This file is part of the Nette Framework (https://nette.org)
5
 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6
 */
7

8
namespace Nette\Neon;
9

10

11
/**
12
 * Simple parser & generator for Nette Object Notation.
13
 * @see https://neon.nette.org
14
 */
15
final class Neon
16
{
17
        public const Chain = '!!chain';
18

19
        /** @deprecated use Neon::Chain */
20
        public const CHAIN = self::Chain;
21

22
        /** @deprecated use parameter $blockMode */
23
        public const BLOCK = Encoder::BLOCK;
24

25

26
        /**
27
         * Returns value converted to NEON.
28
         */
29
        public static function encode(mixed $value, bool $blockMode = false, string $indentation = "\t"): string
1✔
30
        {
31
                $encoder = new Encoder;
1✔
32
                $encoder->blockMode = $blockMode;
1✔
33
                $encoder->indentation = $indentation;
1✔
34
                return $encoder->encode($value);
1✔
35
        }
36

37

38
        /**
39
         * Converts given NEON to PHP value.
40
         */
41
        public static function decode(string $input): mixed
1✔
42
        {
43
                $decoder = new Decoder;
1✔
44
                return $decoder->decode($input);
1✔
45
        }
46

47

48
        /**
49
         * Converts given NEON file to PHP value.
50
         */
51
        public static function decodeFile(string $file): mixed
1✔
52
        {
53
                $input = @file_get_contents($file); // @ is escalated to exception
1✔
54
                if ($input === false) {
1✔
55
                        $error = preg_replace('#^\w+\(.*?\): #', '', error_get_last()['message'] ?? '');
1✔
56
                        throw new Exception("Unable to read file '$file'. $error");
1✔
57
                }
58

59
                if (str_starts_with($input, "\u{FEFF}")) { // BOM
1✔
60
                        $input = substr($input, 3);
×
61
                }
62

63
                return self::decode($input);
1✔
64
        }
65
}
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