Skip to content

Commit 9c78f1a

Browse files
authored
Merge pull request #8 from bavix/dev
update functions
2 parents 72b7ca1 + c10c926 commit 9c78f1a

File tree

1 file changed

+16
-39
lines changed

1 file changed

+16
-39
lines changed

helpers/functions.php

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
'track', 'u', 'ul', 'var', 'video'
2828
];
2929

30-
$tags = \implode('|', $tags);
30+
$tags = \implode('|', $tags);
3131
$attributes = \implode('|', $attributes);
3232

3333
/**
@@ -51,7 +51,7 @@
5151
\define('ATTRIBUTES_REGEX', '/^(' . $attributes . '|data-[\w\-]+)e?s$/');
5252

5353
/**
54-
* @param string $html
54+
* @param string $html
5555
* @param InterfaceCache $cache
5656
*
5757
* @return AdvancedHtmlDom
@@ -64,7 +64,7 @@ function str_get_html($html, InterfaceCache $cache = null)
6464
}
6565

6666
/**
67-
* @param string $html
67+
* @param string $html
6868
* @param InterfaceCache $cache
6969
*
7070
* @return AdvancedHtmlDom
@@ -73,16 +73,15 @@ function strGetHtml($html, InterfaceCache $cache = null)
7373
{
7474
$adv = new AdvancedHtmlDom($html);
7575

76-
if ($cache)
77-
{
76+
if ($cache) {
7877
$adv->setCache($cache);
7978
}
8079

8180
return $adv;
8281
}
8382

8483
/**
85-
* @param string $url
84+
* @param string $url
8685
* @param InterfaceCache $cache
8786
*
8887
* @return AdvancedHtmlDom
@@ -91,32 +90,26 @@ function strGetHtml($html, InterfaceCache $cache = null)
9190
*/
9291
function file_get_html($url, InterfaceCache $cache = null)
9392
{
94-
if ($cache)
95-
{
96-
return str_get_html($cache->get($url));
97-
}
98-
99-
return str_get_html(file_get_contents($url));
93+
return fileGetHtml($url, $cache);
10094
}
10195

10296
/**
103-
* @param string $url
97+
* @param string $url
10498
* @param InterfaceCache $cache
10599
*
106100
* @return AdvancedHtmlDom
107101
*/
108102
function fileGetHtml($url, InterfaceCache $cache = null)
109103
{
110-
if ($cache)
111-
{
104+
if ($cache) {
112105
return strGetHtml($cache->get($url));
113106
}
114107

115108
return strGetHtml(file_get_contents($url));
116109
}
117110

118111
/**
119-
* @param string $html
112+
* @param string $html
120113
* @param InterfaceCache $cache
121114
*
122115
* @return AdvancedHtmlDom
@@ -125,18 +118,11 @@ function fileGetHtml($url, InterfaceCache $cache = null)
125118
*/
126119
function str_get_xml($html, InterfaceCache $cache = null)
127120
{
128-
$adv = new AdvancedHtmlDom($html, true);
129-
130-
if ($cache)
131-
{
132-
$adv->setCache($cache);
133-
}
134-
135-
return $adv;
121+
return strGetXml($html, $cache);
136122
}
137123

138124
/**
139-
* @param string $html
125+
* @param string $html
140126
* @param InterfaceCache $cache
141127
*
142128
* @return AdvancedHtmlDom
@@ -145,16 +131,15 @@ function strGetXml($html, InterfaceCache $cache = null)
145131
{
146132
$adv = new AdvancedHtmlDom($html, true);
147133

148-
if ($cache)
149-
{
134+
if ($cache) {
150135
$adv->setCache($cache);
151136
}
152137

153138
return $adv;
154139
}
155140

156141
/**
157-
* @param string $url
142+
* @param string $url
158143
* @param InterfaceCache $cache
159144
*
160145
* @return AdvancedHtmlDom
@@ -163,26 +148,18 @@ function strGetXml($html, InterfaceCache $cache = null)
163148
*/
164149
function file_get_xml($url, InterfaceCache $cache = null)
165150
{
166-
if ($cache)
167-
{
168-
return str_get_xml($cache->get($url));
169-
}
170-
171-
return str_get_xml(file_get_contents($url));
151+
return fileGetXml($url, $cache);
172152
}
173153

174154
/**
175-
* @param string $url
155+
* @param string $url
176156
* @param InterfaceCache $cache
177157
*
178158
* @return AdvancedHtmlDom
179-
*
180-
* @deprecated fileGetXml
181159
*/
182160
function fileGetXml($url, InterfaceCache $cache = null)
183161
{
184-
if ($cache)
185-
{
162+
if ($cache) {
186163
return strGetXml($cache->get($url));
187164
}
188165

0 commit comments

Comments
 (0)