Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • ArrayNodeDefinition
  • BooleanNodeDefinition
  • EnumNodeDefinition
  • ExprBuilder
  • FloatNodeDefinition
  • IntegerNodeDefinition
  • MergeBuilder
  • NodeBuilder
  • NodeDefinition
  • NormalizationBuilder
  • NumericNodeDefinition
  • ScalarNodeDefinition
  • TreeBuilder
  • ValidationBuilder
  • VariableNodeDefinition

Interfaces

  • NodeParentInterface
  • ParentNodeDefinitionInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: /*
 4:  * This file is part of the Symfony package.
 5:  *
 6:  * (c) Fabien Potencier <fabien@symfony.com>
 7:  *
 8:  * For the full copyright and license information, please view the LICENSE
 9:  * file that was distributed with this source code.
10:  */
11: 
12: namespace Symfony\Component\Config\Definition\Builder;
13: 
14: /**
15:  * Abstract class that contain common code of integer and float node definition.
16:  *
17:  * @author David Jeanmonod <david.jeanmonod@gmail.com>
18:  */
19: abstract class NumericNodeDefinition extends ScalarNodeDefinition
20: {
21:     protected $min;
22:     protected $max;
23: 
24:     /**
25:      * Ensures that the value is smaller than the given reference.
26:      *
27:      * @param mixed $max
28:      *
29:      * @return NumericNodeDefinition
30:      *
31:      * @throws \InvalidArgumentException when the constraint is inconsistent
32:      */
33:     public function max($max)
34:     {
35:         if (isset($this->min) && $this->min > $max) {
36:             throw new \InvalidArgumentException(sprintf('You cannot define a max(%s) as you already have a min(%s)', $max, $this->min));
37:         }
38:         $this->max = $max;
39: 
40:         return $this;
41:     }
42: 
43:     /**
44:      * Ensures that the value is bigger than the given reference.
45:      *
46:      * @param mixed $min
47:      *
48:      * @return NumericNodeDefinition
49:      *
50:      * @throws \InvalidArgumentException when the constraint is inconsistent
51:      */
52:     public function min($min)
53:     {
54:         if (isset($this->max) && $this->max < $min) {
55:             throw new \InvalidArgumentException(sprintf('You cannot define a min(%s) as you already have a max(%s)', $min, $this->max));
56:         }
57:         $this->min = $min;
58: 
59:         return $this;
60:     }
61: }
62: 
php-coveralls API documentation generated by ApiGen 2.8.0