@@ -189,6 +189,9 @@ discard block |
||
| 189 | 189 | return $string; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | + /** |
|
| 193 | + * @param string $string |
|
| 194 | + */ |
|
| 192 | 195 | private static function extractTagAttributes($string) |
| 193 | 196 | { |
| 194 | 197 | $html_attributes = array(); |
@@ -202,6 +205,9 @@ discard block |
||
| 202 | 205 | return $html_attributes; |
| 203 | 206 | } |
| 204 | 207 | |
| 208 | + /** |
|
| 209 | + * @param string $tag_name |
|
| 210 | + */ |
|
| 205 | 211 | private static function filterAllowableTagAttributes($tag_name, $html_attributes) |
| 206 | 212 | { |
| 207 | 213 | // 문자열비교시 대소문자를 가리기때문에, 소문자로 해당값 입력 |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $stack = array(); |
| 56 | 56 | preg_replace_callback( |
| 57 | 57 | '/\<(\/?)([a-z]\w*)([^\>]*)\>/i', |
| 58 | - function ($args) use (&$stack) { |
|
| 58 | + function($args) use (&$stack) { |
|
| 59 | 59 | $tag_opened = (strlen($args[1]) == 0); |
| 60 | 60 | $tag = $args[2]; |
| 61 | 61 | $attr = $args[3]; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // attr가 필수적인것들 |
| 156 | - $is_matched = !!preg_match("/^(" . implode('|', $tags_with_attrs) .")\s+(.+)$/is", trim($tag_and_attr_string), $sub_matches); |
|
| 156 | + $is_matched = !!preg_match("/^(" . implode('|', $tags_with_attrs) . ")\s+(.+)$/is", trim($tag_and_attr_string), $sub_matches); |
|
| 157 | 157 | if ($is_matched) { |
| 158 | 158 | // 태그명 |
| 159 | 159 | $tag_name = $sub_matches[1]; |
@@ -89,6 +89,9 @@ discard block |
||
| 89 | 89 | return $str; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | + /** |
|
| 93 | + * @return string |
|
| 94 | + */ |
|
| 92 | 95 | private static function normalizeSpace($str, $is_single_line = false) |
| 93 | 96 | { |
| 94 | 97 | if ($is_single_line) { |
@@ -170,6 +173,10 @@ discard block |
||
| 170 | 173 | * @param $obj |
| 171 | 174 | * @param $result |
| 172 | 175 | */ |
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * @param \SimpleXMLElement $obj |
|
| 179 | + */ |
|
| 173 | 180 | private static function normalizeSimpleXML($obj, &$result) |
| 174 | 181 | { |
| 175 | 182 | $data = $obj; |
@@ -325,12 +325,12 @@ |
||
| 325 | 325 | $string = substr_replace($string, $sub_string2, $i, strlen($sub_string1)); |
| 326 | 326 | $length -= strlen($sub_string1); |
| 327 | 327 | $length += strlen($sub_string2); |
| 328 | - $i += strlen($sub_string2) - 1; // for문내에서 $i++이기에 |
|
| 328 | + $i += strlen($sub_string2) - 1; // for문내에서 $i++이기에 |
|
| 329 | 329 | } elseif (substr($string, $i, strlen($sub_string2)) == $sub_string2) { |
| 330 | 330 | $string = substr_replace($string, $sub_string1, $i, strlen($sub_string2)); |
| 331 | 331 | $length -= strlen($sub_string2); |
| 332 | 332 | $length += strlen($sub_string1); |
| 333 | - $i += strlen($sub_string1) - 1; // for문내에서 $i++이기에 |
|
| 333 | + $i += strlen($sub_string1) - 1; // for문내에서 $i++이기에 |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | |
@@ -7,69 +7,69 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class ObjectsUtils |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * @param $objects \stdClass[] |
|
| 12 | - * @param $key |
|
| 13 | - * @return array |
|
| 14 | - * |
|
| 15 | - * Objects 에서 특정 key를 가진 값들을 모두 얻기 |
|
| 16 | - * |
|
| 17 | - * $dicts = $db->sqlObjects('select * from tb_book'); |
|
| 18 | - * $b_ids = ObjectsUtils::extractValuesByKey($objects, 'id'); |
|
| 19 | - */ |
|
| 20 | - public static function extractValuesByKey($objects, $key) |
|
| 21 | - { |
|
| 10 | + /** |
|
| 11 | + * @param $objects \stdClass[] |
|
| 12 | + * @param $key |
|
| 13 | + * @return array |
|
| 14 | + * |
|
| 15 | + * Objects 에서 특정 key를 가진 값들을 모두 얻기 |
|
| 16 | + * |
|
| 17 | + * $dicts = $db->sqlObjects('select * from tb_book'); |
|
| 18 | + * $b_ids = ObjectsUtils::extractValuesByKey($objects, 'id'); |
|
| 19 | + */ |
|
| 20 | + public static function extractValuesByKey($objects, $key) |
|
| 21 | + { |
|
| 22 | 22 | $return = []; |
| 23 | - foreach ($objects as $object) { |
|
| 24 | - $return[] = $object->$key; |
|
| 25 | - } |
|
| 26 | - return $return; |
|
| 27 | - } |
|
| 23 | + foreach ($objects as $object) { |
|
| 24 | + $return[] = $object->$key; |
|
| 25 | + } |
|
| 26 | + return $return; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @param $objects |
|
| 31 | - * @param $key |
|
| 32 | - * @return array |
|
| 33 | - * |
|
| 34 | - * Objects 에서 특정 key 를 기준으로 재배치(key 기준으로 하나밖에 없을떄) |
|
| 35 | - * |
|
| 36 | - * $objects = $db->sqlObjects('select * from cpdp_books'); |
|
| 37 | - * $cpdp_books_by_bid = ObjectsUtils::alignByKey($objects, 'b_id'); |
|
| 38 | - * $cpdp_books_111011110 = $tb_book_property_by_bid['111011110']; |
|
| 39 | - * |
|
| 40 | - * $cpdp_books_111011110 => ['id' => '123123', 'b_id'=>'111011110', 'title' => '바람과 함께 사라지다'] |
|
| 41 | - */ |
|
| 42 | - public static function alignByKey($objects, $key) |
|
| 43 | - { |
|
| 44 | - $return = []; |
|
| 45 | - foreach ($objects as $object) { |
|
| 46 | - $return[$object->$key] = $object; |
|
| 47 | - } |
|
| 48 | - return $return; |
|
| 49 | - } |
|
| 29 | + /** |
|
| 30 | + * @param $objects |
|
| 31 | + * @param $key |
|
| 32 | + * @return array |
|
| 33 | + * |
|
| 34 | + * Objects 에서 특정 key 를 기준으로 재배치(key 기준으로 하나밖에 없을떄) |
|
| 35 | + * |
|
| 36 | + * $objects = $db->sqlObjects('select * from cpdp_books'); |
|
| 37 | + * $cpdp_books_by_bid = ObjectsUtils::alignByKey($objects, 'b_id'); |
|
| 38 | + * $cpdp_books_111011110 = $tb_book_property_by_bid['111011110']; |
|
| 39 | + * |
|
| 40 | + * $cpdp_books_111011110 => ['id' => '123123', 'b_id'=>'111011110', 'title' => '바람과 함께 사라지다'] |
|
| 41 | + */ |
|
| 42 | + public static function alignByKey($objects, $key) |
|
| 43 | + { |
|
| 44 | + $return = []; |
|
| 45 | + foreach ($objects as $object) { |
|
| 46 | + $return[$object->$key] = $object; |
|
| 47 | + } |
|
| 48 | + return $return; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @param $objects |
|
| 53 | - * @param $key |
|
| 54 | - * @return array |
|
| 55 | - * |
|
| 56 | - * Objects 에서 특정 key 를 기준으로 재배치(key 기준으로 여러개 있을떄) |
|
| 57 | - * |
|
| 58 | - * $dicts = $db->sqlObjects('select * from tb_book_property'); |
|
| 59 | - * $tb_book_propertys_by_bid = ObjectsUtils::alignListByKey($dicts, 'b_id'); |
|
| 60 | - * $tb_book_propertys_111011110 = $tb_book_propertys_by_bid['111011110']; |
|
| 61 | - * |
|
| 62 | - * $tb_book_propertys_111011110 => [ |
|
| 63 | - * ['b_id'=>'111011110', 'key' => 'num_pages', 'vaule' => 123123], |
|
| 64 | - * ['b_id'=>'111011110', 'key' => 'type', 'vaule' => 'pdf'], |
|
| 65 | - * ] |
|
| 66 | - */ |
|
| 67 | - public static function alignListByKey($objects, $key) |
|
| 68 | - { |
|
| 69 | - $return = []; |
|
| 70 | - foreach ($objects as $object) { |
|
| 71 | - $return[$object->$key][] = $object; |
|
| 72 | - } |
|
| 73 | - return $return; |
|
| 74 | - } |
|
| 51 | + /** |
|
| 52 | + * @param $objects |
|
| 53 | + * @param $key |
|
| 54 | + * @return array |
|
| 55 | + * |
|
| 56 | + * Objects 에서 특정 key 를 기준으로 재배치(key 기준으로 여러개 있을떄) |
|
| 57 | + * |
|
| 58 | + * $dicts = $db->sqlObjects('select * from tb_book_property'); |
|
| 59 | + * $tb_book_propertys_by_bid = ObjectsUtils::alignListByKey($dicts, 'b_id'); |
|
| 60 | + * $tb_book_propertys_111011110 = $tb_book_propertys_by_bid['111011110']; |
|
| 61 | + * |
|
| 62 | + * $tb_book_propertys_111011110 => [ |
|
| 63 | + * ['b_id'=>'111011110', 'key' => 'num_pages', 'vaule' => 123123], |
|
| 64 | + * ['b_id'=>'111011110', 'key' => 'type', 'vaule' => 'pdf'], |
|
| 65 | + * ] |
|
| 66 | + */ |
|
| 67 | + public static function alignListByKey($objects, $key) |
|
| 68 | + { |
|
| 69 | + $return = []; |
|
| 70 | + foreach ($objects as $object) { |
|
| 71 | + $return[$object->$key][] = $object; |
|
| 72 | + } |
|
| 73 | + return $return; |
|
| 74 | + } |
|
| 75 | 75 | } |