source: branches/version-2_12-dev/tests/class/test/util/Test_Utils.php @ 22567

Revision 22567, 2.5 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

  • Property svn:keywords set to Id Rev Date
Line 
1<?php
2
3/*
4 * This file is part of EC-CUBE
5 *
6 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
7 *
8 * http://www.lockon.co.jp/
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23 */
24
25/**
26 * テストケースで使う一般的なユーティリティを持つクラス.
27 *
28 * @author Hiroko Tamagawa
29 * @version $Id$
30 */
31class Test_Utils
32{
33
34  /**
35   * 連想配列から指定されたキーだけを抜き出したものを返します.
36   * 入力の連想配列には変更を加えません.
37   *
38   * @static
39   * @param input_array 入力の連想配列
40   * @param map_keys 出力結果に入れたいキーを配列で指定します
41   * @return 指定したキーのみを持つ連想配列
42   */
43  public static function mapArray($input_array, $map_keys)
44  {
45    $output_array = array();
46    foreach ($map_keys as $index => $map_key) {
47      $output_array[$map_key] = $input_array[$map_key];
48    }
49
50    return $output_array;
51  }
52
53  /**
54   * 配列の各要素(連想配列)から特定のキーだけを抜き出した配列を返します.
55   * 入力の連想配列には変更を加えません.
56   *
57   * @static
58   * @param input_array 入力の配列
59   * @param key 抽出対象のキー
60   * @return 指定のキーだけを抜き出した配列
61   */
62  public static function mapCols($input_array, $key)
63  {
64    $output_array = array();
65    foreach ($input_array as $data) {
66      $output_array[] = $data[$key];
67    }
68   
69    return $output_array;
70  }
71
72  /**
73   * 配列に別の配列をappendします。
74   * $orig_arrayが直接変更されます。
75   *
76   * @static
77   * @param orig_array 追加先の配列
78   * @param new_array 追加要素を持つ配列
79   */
80  public static function array_append(&$orig_array, $new_array)
81  {
82    foreach ($new_array as $element) {
83      $orig_array[] = $element;
84    }
85  }
86}
87
Note: See TracBrowser for help on using the repository browser.