public function withScript(ScriptElement $script, $scope = 'header')
    {
        // These are the only legal values.
        assert(in_array($scope, ['header', 'footer']));

        $that = clone($this);
        $that->scripts[$scope][] = $script;
        return $that;
    }
public function withScript(ScriptElement $script, $scope = 'header')
    {
        // These are the only legal values.
        assert(in_array($scope, ['header', 'footer']));

        $that = clone($this);
        $that->scripts[$scope][] = $script;
        return $that;
    }
public function withScript ( ScriptElement $ script , $ scope = 'header' ) { // These are the only legal values. assert ( in_array ( $ scope , [ 'header' , 'footer' ] ) ) ; $ that = clone ( $ this ) ; $ that -> scripts [ $ scope ] [ ] = $ script ; return $ that ; }
Returns a copy of the page with the script added.

@param ScriptElement $script
@param string $scope
The scope in which the script should be defined. Legal values are "header"
(i.e., in the <head> element) and "footer" (i.e., right before </body>).

@return static
Returns a copy of the page with the script added .