aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/3rdparty/htmlpurifier/HTMLPurifier/ConfigSchema/ValidatorAtom.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2015-01-18 20:07:46 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2015-01-18 20:07:46 +0100
commitadf17b677edeb2387671f6a0f12123e7497b5938 (patch)
tree8fd87d7bf5699488ffc12afa991011e80ac1011b /inc/3rdparty/htmlpurifier/HTMLPurifier/ConfigSchema/ValidatorAtom.php
parent894cd087f41d605f2f093aaad1300825f705e009 (diff)
downloadwallabag-adf17b677edeb2387671f6a0f12123e7497b5938.tar.gz
wallabag-adf17b677edeb2387671f6a0f12123e7497b5938.tar.zst
wallabag-adf17b677edeb2387671f6a0f12123e7497b5938.zip
remove 3rd libraries
Diffstat (limited to 'inc/3rdparty/htmlpurifier/HTMLPurifier/ConfigSchema/ValidatorAtom.php')
-rw-r--r--inc/3rdparty/htmlpurifier/HTMLPurifier/ConfigSchema/ValidatorAtom.php130
1 files changed, 0 insertions, 130 deletions
diff --git a/inc/3rdparty/htmlpurifier/HTMLPurifier/ConfigSchema/ValidatorAtom.php b/inc/3rdparty/htmlpurifier/HTMLPurifier/ConfigSchema/ValidatorAtom.php
deleted file mode 100644
index a2e0b4a1..00000000
--- a/inc/3rdparty/htmlpurifier/HTMLPurifier/ConfigSchema/ValidatorAtom.php
+++ /dev/null
@@ -1,130 +0,0 @@
1<?php
2
3/**
4 * Fluent interface for validating the contents of member variables.
5 * This should be immutable. See HTMLPurifier_ConfigSchema_Validator for
6 * use-cases. We name this an 'atom' because it's ONLY for validations that
7 * are independent and usually scalar.
8 */
9class HTMLPurifier_ConfigSchema_ValidatorAtom
10{
11 /**
12 * @type string
13 */
14 protected $context;
15
16 /**
17 * @type object
18 */
19 protected $obj;
20
21 /**
22 * @type string
23 */
24 protected $member;
25
26 /**
27 * @type mixed
28 */
29 protected $contents;
30
31 public function __construct($context, $obj, $member)
32 {
33 $this->context = $context;
34 $this->obj = $obj;
35 $this->member = $member;
36 $this->contents =& $obj->$member;
37 }
38
39 /**
40 * @return HTMLPurifier_ConfigSchema_ValidatorAtom
41 */
42 public function assertIsString()
43 {
44 if (!is_string($this->contents)) {
45 $this->error('must be a string');
46 }
47 return $this;
48 }
49
50 /**
51 * @return HTMLPurifier_ConfigSchema_ValidatorAtom
52 */
53 public function assertIsBool()
54 {
55 if (!is_bool($this->contents)) {
56 $this->error('must be a boolean');
57 }
58 return $this;
59 }
60
61 /**
62 * @return HTMLPurifier_ConfigSchema_ValidatorAtom
63 */
64 public function assertIsArray()
65 {
66 if (!is_array($this->contents)) {
67 $this->error('must be an array');
68 }
69 return $this;
70 }
71
72 /**
73 * @return HTMLPurifier_ConfigSchema_ValidatorAtom
74 */
75 public function assertNotNull()
76 {
77 if ($this->contents === null) {
78 $this->error('must not be null');
79 }
80 return $this;
81 }
82
83 /**
84 * @return HTMLPurifier_ConfigSchema_ValidatorAtom
85 */
86 public function assertAlnum()
87 {
88 $this->assertIsString();
89 if (!ctype_alnum($this->contents)) {
90 $this->error('must be alphanumeric');
91 }
92 return $this;
93 }
94
95 /**
96 * @return HTMLPurifier_ConfigSchema_ValidatorAtom
97 */
98 public function assertNotEmpty()
99 {
100 if (empty($this->contents)) {
101 $this->error('must not be empty');
102 }
103 return $this;
104 }
105
106 /**
107 * @return HTMLPurifier_ConfigSchema_ValidatorAtom
108 */
109 public function assertIsLookup()
110 {
111 $this->assertIsArray();
112 foreach ($this->contents as $v) {
113 if ($v !== true) {
114 $this->error('must be a lookup array');
115 }
116 }
117 return $this;
118 }
119
120 /**
121 * @param string $msg
122 * @throws HTMLPurifier_ConfigSchema_Exception
123 */
124 protected function error($msg)
125 {
126 throw new HTMLPurifier_ConfigSchema_Exception(ucfirst($this->member) . ' in ' . $this->context . ' ' . $msg);
127 }
128}
129
130// vim: et sw=4 sts=4