FOSSology  4.4.0
Open Source License Compliance by Open Source Software
libCopyRight.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2010 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
21 function cleanString($string)
22 {
23  $clean = NULL;
24  if(strlen($string) == 0)
25  {
26  return($clean);
27  }
28  $cleanText = str_replace("\n", '', $string);
29  $clean = trim($cleanText);
30  return($clean);
31 }
32 
52 function checkStandard($list, $standard, $testName)
53 {
54  if(empty($list))
55  {
56  return(array('ERROR! empty list passed in'));
57  }
58  if(empty($standard))
59  {
60  return(array('ERROR! empty Standard list passed in'));
61  }
62  if((strlen($testName)) == 0)
63  {
64  return(array('ERROR! no testName supplied'));
65  }
66 
67  $results = array();
68 
69  foreach($list as $uiData) {
70  $cleanText = cleanString($uiData['textOrLink']);
71  print "ckSTDB: cleanText is:$cleanText\n";
72  if (array_key_exists($cleanText, $standard)) {
73  $stdCount = $standard[$cleanText];
74  if($stdCount != $uiData['count'])
75  {
76  $results[] = "$testName FAILED! Should be $stdCount files " .
77  "got:$uiData[count] for row with text:\n$cleanText\n";
78  }
79  }
80  else
81  {
82  $results[] = "$testName FAILED! $cleanText did not meet the test Standard\n";
83  }
84  }
85  //print "ckStdDB: results are:\n";print_r($results) . "\n";
86  return($results);
87 }
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:690