/** * Set average cadence from array */ private function setAvgCadenceFromArray() { $array = $this->TrainingObject->getArrayCadence(); if (!empty($array) && max($array) > 30) { $array = array_filter($array, 'ParserAbstract__ArrayFilterForLowEntries'); $this->TrainingObject->setCadence(round(array_sum($array) / count($array))); } }
protected function checkArraySizes(\TrainingObject $object) { $arrays = array('elevation' => $object->getArrayAltitudeOriginal(), 'cadence' => $object->getArrayCadence(), 'distance' => $object->getArrayDistance(), 'heartrate' => $object->getArrayHeartrate(), 'latitude' => $object->getArrayLatitude(), 'longitude' => $object->getArrayLongitude(), 'time' => $object->getArrayTime()); $num = 0; $fails = false; $result = array(); foreach ($arrays as $key => $array) { $count = count($array); if ($count > 1) { if ($num == 0) { $num = $count; } elseif ($num != $count) { $fails = true; } $result[$key] = $count; } } $this->assertFalse($fails, print_r($result, true)); }
/** * Set average cadence from array */ private function setAvgCadenceFromArray() { $array = $this->TrainingObject->getArrayCadence(); $this->TrainingObject->setCadence(round(array_sum($array) / count($array))); }