(function(window) {
var videoNode = window.document.querySelector('#myvideo');
var timeNode = window.document.querySelector('.time');
videoNode.addEventListener('loadedmetadata', function(e) {
var duration = videoNode.duration.toFixed(1);
var m = duration % 60;
timeNode.innerText = Math.floor(duration / 60) + ':' + (m < 10 ? '0' : '') + m;
});
})(window);
<?
class City {
private $length;
function __construct($length) {
$this->length = $length;
}
public function getLength() {
return $this->length;
}
}
class Auto {
private $speed;
function __construct($speed) {
$this->speed = $speed;
}
public function getSpeed() {
return $this->speed;
}
public function howLongToGo($length) {
return $length / $this->speed;
}
public function howLongToGoThrowCity(City $city) {
return $city->getLength() / $this->speed;
}
}
$a = new Auto(20);
$c = new City(100);
print $a->howLongToGo($c->getLength());
// Или так
print $a->howLongToGoThrowCity($c);